-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
106 lines (97 loc) · 2.55 KB
/
webpack.config.js
File metadata and controls
106 lines (97 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
const NODE_ENV = process.env.NODE_ENV || 'development';
const webpack = require('webpack');
let ExtractTextPlugin = require("extract-text-webpack-plugin");
//let HtmlWebpackPlugin = require('html-webpack-plugin');
let CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
context: __dirname + '/src',
entry: {
main: [
'webpack-dev-server/client?http://localhost:8080',
'./js/main'
],
styles: './styles/main.styl'
},
output: {
path: __dirname + '/build/',
filename: "./js/[name].js",
publicPath: "/"
},
devtool: "cheap-inline-module-source-map",
plugins: [
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
NODE_ENV: JSON.stringify(NODE_ENV)
}),
new webpack.optimize.CommonsChunkPlugin({
name: "common",
chunks: ['home', 'about']
}),
new ExtractTextPlugin('./css/main.css', {allChunks: true}),
/*new HtmlWebpackPlugin({
template: './index.html'
}),*/
new webpack.HotModuleReplacementPlugin(),
new CopyWebpackPlugin([
{
from: './img',
to: 'img/'
},
{
context: './',
from: '**/*.html',
to: './'
},
{
context: './',
from: '**.pug',
to: './'
},
], {
copyUnmodified: true
})
],
resolve: {
modulesDirectories: ['node_modules'],
extensions: ['', '.js']
},
resolveLoader: {
modulesDirectories: ['node_modules'],
moduleTemplates: ['*-loader', '*'],
extensions: ['', '.js']
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
plugins: ['transform-runtime']
},
{
test: /\.html$/,
loader: 'file?name=[path][name].[ext]'
},
{
test: /\.pug$/,
loader: 'pug-loader'
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css!autoprefixer?browsers=last 2 version')
},
{
test: /\.styl$/,
loader: ExtractTextPlugin.extract('css!autoprefixer?browsers=last 2 version!stylus?resolve url')
},
{
test: /\.(png|jpg|svg|ttf|eot|woff|woff2)$/,
loader: 'file?name=[path][name].[ext]'
}
]
},
devServer: {
inline: true,
historyApiFallback: true,
outputPath: "./build"
}
};