-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
86 lines (78 loc) · 2.17 KB
/
webpack.config.js
File metadata and controls
86 lines (78 loc) · 2.17 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
var webpack = require('webpack'),
OpenBrowserPlugin = require('open-browser-webpack-plugin'),
Dashboard = require('webpack-dashboard'),
DashboardPlugin = require('webpack-dashboard/plugin'),
WebpackDevServer = require('webpack-dev-server'),
CleanPlugin = require('clean-webpack-plugin'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
path = require('path');
var dashboard = new Dashboard();
// var getEntry = function() {
// var entry = {};
// //读取开发目录,并进行路径裁剪
// glob.sync('./src/**/*.es6')
// .forEach(function(name) {
// var start = name.indexOf('src/') + 4,
// end = name.length - 3;
// var n = name.slice(start, end);
// n = n.slice(0, n.lastIndexOf('/'));
// //保存各个组件的入口
// entry[n] = name;
// });
// return entry;
// };
module.exports = {
entry: {
path: path.join(__dirname, './src/app/app')
},
// entry: getEntry(),
output: {
path: path.join(__dirname, './dist/'),
filename: 'app.js'
},
devtool: 'source-map',
module: {
loaders: [
{
test: /\.es6$/,
loader: 'babel-loader'
},
{
test: /\.coffee$/,
loader: 'coffee-loader'
},
{
test: /\.css$/,
loader: 'style!css'
}
]
},
resolve: {
extensions: ['', '.js', '.coffee', '.es6']
},
plugins:[
new HtmlWebpackPlugin({
filename: 'index.html',
template: './index.html'
}),
new CleanPlugin(['dist']),
// 启动热替换
new webpack.HotModuleReplacementPlugin(),
new OpenBrowserPlugin({
url: 'http://localhost:3002/'
}),
// new DashboardPlugin
new DashboardPlugin(dashboard.setData)
],
}
module.exports.devtool = 'source-map';
module.exports.devServer = {
port: 3002,
contentBase: './dist',
hot: true,
historyApiFallback: true,
publicPath: "",
stats: {
colors: true
}
};