-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.dev.config.js
64 lines (59 loc) · 1.91 KB
/
webpack.dev.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
var webpack = require('webpack');
var path = require('path');
var HtmlwebpackPlugin = require('html-webpack-plugin');
var ROOT_PATH = path.resolve(__dirname);
var APP_PATH = path.resolve(ROOT_PATH, 'src');
var BUILD_PATH = path.resolve(ROOT_PATH, 'build');
var node_modules_PATH = path.resolve(ROOT_PATH,'node_modules');
var config = {
entry: {
src: path.resolve(APP_PATH, 'app')
},
output: {
path: BUILD_PATH,
filename:'bundle.js'
},
resolve: {
root: __dirname,
extensions: ['', '.ts', '.js', '.json'],
alias:{
'jquery':path.resolve(node_modules_PATH, 'jquery/dist/jquery.min')
}
},
devServer: {
hot: true,
inline: true
},
module: {
loaders: [
{ test: /\.html$/, exclude: /node_modules/, loader: 'raw-loader?stage=0'},
/*安装babel-loader babel-core babel-preset-es2015*/
{ test: /\.js$/, exclude: /(node_modules|bower_components)/,include: APP_PATH, loader: 'babel', query:{ presets: ['es2015'] } },//ES6
{test: /\.ts(x?)$/, loader: 'ts-loader', exclude: /node_modules/},
]
},
plugins: [
new HtmlwebpackPlugin({
title: 'webpack-angular',
template:'./src/index.html',
inject:'body'
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
}),
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false }
}),
new webpack.NoErrorsPlugin(),
new webpack.optimize.DedupePlugin(),
//【2】注意这里 这两个地方市用来配置common.js模块单独打包的
//多个文件应用一个js
new webpack.optimize.CommonsChunkPlugin({
name: "vendor",//和上面配置的入口对应
filename: "vendor.js"//导出的文件的名称
})
]
}
module.exports = config