-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
66 lines (65 loc) · 2.08 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
var webpack = require('webpack');
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
index: "./app.js"
},
output: {
path: "./dist/",
filename: "js/[name].js",
chunkFilename: "js/[name].js"
},
module: {
loaders: [
{
test: /\.less$/,
loader: 'style-loader!css-loader!less-loader'
},
{
test: /\.css$/,
loader: "style!css"
},
{
// 在页面中加载图片示例:var imgstr = require("./imgs/3.png");
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'url?limit=8192&name=./static/images/[name]_[hash].[ext]'
// 'image-webpack?{bypassOnDebug:true, progressive:true, optimizationLevel: 7, interlaced: false, pngquant:{quality: "65-90", speed: 4}}'
]
},
{
test: /\.html$/,
loader: 'html'
},
{
// 编译es6
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader"
}
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
//把common中的所有的js打包成一个common.js
name: "common",
// filename: "common.js"
// (Give the chunk a different name)
minChunks: Infinity
// (with more entries, this ensures that no other module
// goes into the vendor chunk)
}),
new HtmlWebpackPlugin({
title: '标题标题',
template: './src/index.html', // 源模板文件
filename: './index.html', // 输出文件【注意:这里的根路径是module.exports.output.path】
inject: true,
minify: {
removeComments: true,
collapseWhitespace: true
},
chunks: ["common","index"]
})
]
};