-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.prod.js
66 lines (65 loc) · 2.08 KB
/
webpack.config.prod.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
var path = require('path');
var HtmlwebpackPlugin = require('html-webpack-plugin');
var webpack = require('webpack');
var ROOT_PATH = path.resolve(__dirname);
var APP_PATH = path.resolve(ROOT_PATH, 'app');
var BUILD_PATH = path.resolve(ROOT_PATH, 'build');
module.exports = {
devtool: 'cheap-source-map',
// 默认寻找文件夹下面的index.js文件
entry: {
app: path.resolve(APP_PATH, 'index.jsx'),
},
output: {
path: BUILD_PATH,
filename: '[name].[hash].js'
},
resolve: {
extensions: ['', '.js', '.jsx']
},
module: {
loaders: [
{
test: /\.jsx?$/,
loader: 'babel',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react', 'stage-0'],
plugins: ['transform-runtime', 'transform-object-rest-spread']
}
},
{
test: /(\.scss|\.css)$/,
loaders: ["style", "css", "sass"],
include: [
APP_PATH,
path.resolve(ROOT_PATH, 'styles'),
path.resolve(ROOT_PATH, 'node_modules/font-awesome'),
path.resolve(ROOT_PATH, 'node_modules/react-validation-form'),
path.resolve(ROOT_PATH, 'node_modules/react-s-alert'),
]
},
{
test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/,
loader: 'url-loader?limit=50000&name=[path][name].[ext]'
},
]
},
plugins: [
new HtmlwebpackPlugin({
title: '可视化编程'
}),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false },
comments: false,
drop_console: true,
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
'__SERVER__': false,
'__CLIENT__': true,
}),
],
};