-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
77 lines (76 loc) · 2.71 KB
/
webpack.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
/**
* Created by daijiaru on 2016/9/18.
*/
let path = require('path');
let webpack = require('webpack');
let ExtractTextPlugin = require("extract-text-webpack-plugin");
let autoprefixer = require('autoprefixer');
module.exports = {
devtool: 'inline-source-map',
entry: {
index:'webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000',
weather: "./app/weather.js"
},
output: {
path: path.resolve(__dirname, './build'),
filename: '[name].js',
publicPath: '/'
},
resolve: {
extensions: ['', '.js', 'jsx'],
},
module: {
loaders: [
{
test: /\.js(x)?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel',
query: {
presets: ['es2015', 'react']
}
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style', 'css!postcss!sass')
}, {
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css!postcss')
},
{ test: /\.(png|jpg|jpeg|gif)$/, loader: 'url-loader?limit=10000'},
{ test: /\.woff2?$/, loader: 'url?limit=10000&minetype=application/font-woff' },
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff" },
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/octet-stream" },
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file" },
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=image/svg+xml" },
{ test: /\.json$/, loader: 'json'}
]
},
postcss: [
autoprefixer({
browsers: ['last 2 versions', 'Firefox ESR', '> 1%', 'ie >= 8']
})
],
plugins: [
new webpack.HotModuleReplacementPlugin(),
new ExtractTextPlugin('[name].css'),
new webpack.optimize.UglifyJsPlugin({
test: /(\.jsx|\.js)$/,
compress: {
warnings: false
}
}),
new webpack.optimize.CommonsChunkPlugin('common.js', '[name]'),
/*ProvidePlugin 插件可以定义一个共用的入口,比如 下面加的 React ,他会在每个文件自动
require了react,所以你在文件中不需要 require('react'),也可以使用 React。*/
new webpack.ProvidePlugin({
React: 'react',
ReactDOM: 'react-dom',
$:'jquery'
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}),
]
};