-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.production.config.js
84 lines (79 loc) · 2.71 KB
/
webpack.production.config.js
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
/**
* Created by HH on 2017/3/3.
*/
var path = require('path');
var webpack = require('webpack');
var WebpackMd5Hash = require('webpack-md5-hash');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
app: './src/components/app.js',
vendors:['react','react-dom']
},
output: {
path: path.join(__dirname, 'dist/'),
publicPath: '',
// filename: 'dev.js'
filename: '[name]-[chunkhash:8].js',
chunkFilename: '[name]-[chunkhash:8].js' //路由对应文件
},
plugins: [
new ExtractTextPlugin('style-[contenthash:8].css'),
// new webpack.optimize.OccurrenceOrderPlugin(), //已被默认加载
new webpack.optimize.CommonsChunkPlugin({
names:'vendors',
filename: 'vendors-[chunkhash:8].js',
minChunks:Infinity
}),
new webpack.optimize.UglifyJsPlugin({
output:{
comments:false, //去掉所以注释
},
compress:{
warnings:false
}
}),
// new webpack.NoErrorsPlugin(); //排除报错的插件
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
}),
// new CopyWebpackPlugin([
// { from: './index.html', to: 'index.html' }
// ]),
new HtmlWebpackPlugin({
template: __dirname + "/index.html"
}),
new WebpackMd5Hash()
],
module: {
loaders: [{
// test: /\.css$/,
// loaders: ['style-loader', 'css-loader']
// }, {
test: /\.(js|jsx)$/,
loader: 'babel-loader',
// loader: ['babel-loader','eslint-loader'],
exclude: /node_modules/,
query: {
presets: ['es2015', 'react', 'stage-0']
}
}, {
test: /\.(scss|css)/,
// loader: 'style-loader!css-loader!autoprefixer-loader?{browsers:["last 2 version","IE 8"]}!sass-loader?outputStyle=expanded'
use: ExtractTextPlugin.extract({
fallback:"style-loader",
use:["css-loader","autoprefixer-loader?{browsers:['last 2 version','IE 8']}","sass-loader"],
publicPath: "" //css需要的资源的路径
})
//loader: 'style-loader!css-loader!autoprefixer-loader!sass-loader'
//loader: 'style-loader!css-loader!autoprefixer-loader!sass-loader!resolve-url!'
},{
// test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/,
test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/,
loader: 'url-loader?limit=5000&name=[path][name].[ext]'
}]
}
}