-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.dev.config.js
More file actions
78 lines (75 loc) · 2.08 KB
/
webpack.dev.config.js
File metadata and controls
78 lines (75 loc) · 2.08 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
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var HtmlWebpackPlugin = require('html-webpack-plugin');
var autoprefixer = require('autoprefixer');
var postPxToEm = require('postcss-px-to-em');
process.argv.forEach(function (item) {
if (item === 'auto') {
process.env.AUTO = '1';
} else if (item === 'https') {
process.env.HTTPS = '1';
}
});
module.exports = {
entry: {
app: ['./src/index.js']
},
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/',
filename: 'js/[name].js',
chunkFilename: "js/chunk/[name].js"
},
resolveLoader: {
root: path.join(__dirname, 'node_modules')
},
resolve: {
extensions: ['', '.js'],
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loaders: ['babel-loader']
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'url?limit=10000&name=images/[name].[ext]'
},
{
test: /\.(woff|eot|ttf).*?$/i,
loader: 'url?limit=10000&name=fonts/[name].[ext]'
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css!postcss')
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style', 'css!postcss!sass')
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html',
filename: 'index.html',
inject: 'body'
}),
new ExtractTextPlugin('css/[name].css'),
new webpack.DefinePlugin({
__DEV__: true
})
],
postcss: function () {
return [autoprefixer, postPxToEm({base: 16})];
},
devtool: 'cheap-module-eval-source-map'
};
if (process.env.AUTO === '1') {
module.exports.plugins.push(
new webpack.HotModuleReplacementPlugin()
);
}