-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
124 lines (114 loc) · 2.97 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
var webpack = require('webpack');
var path = require('path');
var distPath = path.resolve(__dirname, 'dist');
var TransferWebpackPlugin = require('transfer-webpack-plugin');
// webpack.config.js
module.exports = {
// entry: [
// path.join(__dirname, 'index.js'),
// path.join(__dirname, 'index.ng.js'),
// // path.join(__dirname, 'index.jq.js')
// ],
entry: {
common: [
path.join(__dirname, 'index.js')
],
ng: [
path.join(__dirname, 'index.ng.js')
]
},
//Server Configuration options
// devServer: {
// contentBase: '', //静态资源的目录 相对路径,相对于当前路径 默认为当前config所在的目录
// devtool: 'eval',
// hot: true, //自动刷新
// inline: true,
// port: 3005
// },
// devtool: 'eval',
output: {
path: distPath,
// filename: '$resource.js'
filename: '$resource.[name].js',
library: 'resource',
libraryTarget: 'umd'
// chunkFilename: '[name].[chunkhash:8].js'
},
resolve: {
extensions: ['', '.coffee', '.js']
},
module: {
loaders: [
{
test: /\.(jsx|js)?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel', // 'babel-loader' is also a legal name to reference
query: {
presets: ['es2015'],
plugins: [
'transform-flow-strip-types',
'transform-es2015-block-scoping',
'transform-regenerator'
// 'transform-runtime'
]
}
}
]
},
plugins: [
// new webpack.HotModuleReplacementPlugin(),
//js文件的压缩
// new webpack.optimize.UglifyJsPlugin({
// compress: {
// warnings: false
// },
// mangle: {
// except: ['$super', '$', 'exports', 'require']
// }
// }),
// 添加banner
new webpack.BannerPlugin((function () {
return `
/*
${new Date().toISOString()}
*/
`;
})(), {
raw: true,
entryOnly: false
}),
// 删除重复的代码
// new webpack.optimize.DedupePlugin(),
// new webpack.DllPlugin({
// path: path.join(__dirname, "manifest.json"),
// name: "[name]_[hash]",
// context: __dirname
// }),
// 生成source map
new webpack.SourceMapDevToolPlugin({
// asset matching
test: /\.(jsx|js)?$/,
exclude: /(node_modules|bower_components)/,
// include: string | RegExp | Array,
// file and reference
filename: '$resource.map',
append: false,
// sources naming
moduleFilenameTemplate: '$resource.map',
fallbackModuleFilenameTemplate: '$resource.map',
// quality/performance
module: true,
columns: true,
lineToLine: true
}),
//允许错误不打断程序
// new webpack.NoErrorsPlugin(),
// //把指定文件夹下的文件复制到指定的目录
// new TransferWebpackPlugin([
// {
// from: 'src',
// to: 'src'
// }
// ], __dirname)
]
};