-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
88 lines (88 loc) · 2.56 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
var htmlWebpackPlugin = require('html-webpack-plugin');
var path = require('path');
module.exports = {
entry:'./src/app.js',
// {
// main:"./src/script/main.js",
// a:'./src/script/a.js',
// b:'./src/script/b.js',
// c:'./src/script/c.js'
// },
output:{
path:__dirname + '/dist',
filename:'js/[name]-[chunkhash].js',
// publicPath:'http://b2b.sunrf.cn'
},
module:{
rules: [
{
test: /\.js$/,
exclude: path.resolve(__dirname,'node_modules'),//包含的文件夹
include: path.resolve(__dirname,'src'),//包含的文件夹
loader: "babel-loader"
},
{
test: /\.(png|jpg|jpeg|svg|gif)$/i,
loader:'file-loader',
query:{
limit:2000,
name:'assets/[name]-[hash:5].[ext]'
}
},
{
test: /\.tpl$/,
loader:'ejs-loader'
},
{
test: /\.html$/,
loader:'html-loader'
},
{
test: /\.css$/,
use: [
'style-loader',
{ loader: 'css-loader', options: { importLoaders: 1 } },
'postcss-loader'
]
},
{
test: /\.less$/,
use: [
'style-loader',
{ loader: 'css-loader', options: { importLoaders: 1 } },
'postcss-loader',
'less-loader'
]
}
]
},
plugins:[
new htmlWebpackPlugin({
filename:'index.html',
template:'index.html',
inject:'body',
title:'webpack a',
date: new Date(),
// minify:{
// removeComments:true,
// collapseWhitespace:true
// },
// chunks:['main','a'],//包含哪些chunks
// excludeChunks:['b','c'] //排除的chunks
}),
// new htmlWebpackPlugin({
// filename:'b.html',
// template:'index.html',
// inject:'body',
// title:'webpack b',
// excludeChunks:['a','c']
// }),
// new htmlWebpackPlugin({
// filename:'c.html',
// template:'index.html',
// inject:'body',
// title:'webpack c',
// excludeChunks:['a','b']
// })
]
}