forked from ziaochina/reactMonkey
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
99 lines (94 loc) · 3.25 KB
/
webpack.config.js
File metadata and controls
99 lines (94 loc) · 3.25 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var config = require('./web.config.js')
var ExtractTextPlugin = require("extract-text-webpack-plugin")
var HtmlWebpackPlugin = require('html-webpack-plugin')
var CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
devtool: 'source-map',
entry: {
main: './src/index.js'
},
output: {
path: __dirname + '/dist',
filename: '[name].bundle.js',
chunkFilename: '[name].chunk.js'
},
module: {
loaders: [
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
plugins: ['transform-runtime', 'transform-decorators-legacy', 'antd'],
presets: ['react', 'es2015', 'stage-0']
}
}, {
test: /\.less$/,
loader: 'style!css?importLoaders=1!autoprefixer!less'
}, {
test: /\.(jpg|png|svg|woff|woff2)$/,
exclude: /node_modules/,
loader: "url-loader?limit=8192" //图片文件使用 url-loader 来处理,小于8kb的直接转为base64
}, {
test: /\.(ttf|eot)$/,
loader: 'file'
}
]
},
resolve: {
extensions: ['', '.js', '.jsx'],
alias: {
xComponent: __dirname + '/src/component/index.js',
appLoader: __dirname + '/src/appLoader/index.js',
dynamicComponent: __dirname + '/src/apps/dynamicUI/index.js',
dynamicAction: __dirname + '/src/apps/dynamicUI/action.js',
dynamicReducer: __dirname + '/src/apps/dynamicUI/reducer.js'
}
},
plugins: [
new CopyWebpackPlugin([{
context: './src/vendor',
from: '**/*',
to: './vendor'
}, {
context: './src/assets/iconfont',
from: '**/*',
to: 'iconfont'
}]),
new webpack.HotModuleReplacementPlugin(),
new webpack.ProvidePlugin({
'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch'
}),
//生成环境
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"'
}),
/*
//代码丑化
new webpack.optimize.UglifyJsPlugin({
minimize: true,
sourceMap:false,
mangle:false,
compressor: {
warnings: false
}
}),*/
new HtmlWebpackPlugin({
title: 'demo', //标题
favicon: './src/assets/img/favicon.ico', //favicon路径
filename: './index.html', //生成的html存放路径,相对于 path
template: './src/index.html', //html模板路径
inject: true, //允许插件修改哪些内容,包括head与body
hash: true, //为静态资源生成hash值
minify: { //压缩HTML文件
removeComments: true, //移除HTML中的注释
collapseWhitespace: false //删除空白符与换行符
}
})
],
postcss: function() {
return [autoprefixer];
},
};