-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
49 lines (48 loc) · 1.21 KB
/
webpack.config.js
File metadata and controls
49 lines (48 loc) · 1.21 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
const webpack = require('webpack');
const path = require('path');
const HtmlwebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
let env = process.env.WEBPACK_ENV;
let outputFile;
let plugins = [
new ExtractTextPlugin("[name][hash:8].css"),
new HtmlwebpackPlugin({
title: 'suprise word GE',
template: './app/index.html',
filename: 'index.html'
})
]
if (env === 'build') {
plugins.push(new UglifyJsPlugin({
minimize: true
}));
outputFile = 'bundle.min.js';
} else {
outputFile = 'bundle.js';
}
const config = {
entry: [
'webpack/hot/dev-server',
'webpack-dev-server/client?http://localhost:8000',
'./app/index.js'
],
output: {
path: path.resolve(__dirname, 'dist'),
filename: outputFile
},
devtool: 'source-map',
module: {
//加载器配置
loaders: [{
test: /\.less$/,
loader: ExtractTextPlugin.extract("style-loader", "css-loader!less-loader")
}, {
test: /\.js/,
exclude: /node_modules/,
loader: 'babel-loader?presets[]=es2015&presets[]=stage-0&presets[]=react'
}]
},
plugins: plugins
}
module.exports = config;