webpack.common.js
2.77 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
87
88
89
90
91
92
93
94
95
96
const path = require('path')
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const htmlTemplateProcess = new HtmlWebpackPlugin({
template:'html-withimg-loader!' + path.resolve(__dirname,'../src/taskProcess.html'),
hash:true,
chunks:['common','taskProcess'],
inject: true,
minify:false,
filename:'taskProcess.html',
})
const htmlTemplateIndex = new HtmlWebpackPlugin({
template:'html-withimg-loader!' + path.resolve(__dirname,'../src/index.html'),
hash:true,
// chunks:['common','list'],
chunks:['common','index'],
inject: true,
minify:false,
filename:'index.html'
})
const htmlTemplateFission = new HtmlWebpackPlugin({
template:'html-withimg-loader!' + path.resolve(__dirname,'../src/fission.html'),
hash:true,
// chunks:['common','list'],
chunks:['common','fission'],
inject: true,
minify:false,
filename:'fission.html'
})
var dev = {
entry : {
'taskProcess':'./src/js/taskProcess.js',
'fission':'./src/js/fission.js',
'index':'./src/js/index.js',
'common':'./src/js/common.js'
},
resolve:{
extensions:['.ts','.tsx','.js','.json']
},
module: {
rules: [
{
test: /\.js$/, // 匹配文件路径的正则表达式,通常我们都是匹配文件类型后缀
exclude: "/node_modules/",
loader: 'babel-loader', // 指定使用的 loader
},
{test:/\.css$/,
exclude: /node_modules/,
// loader:'style-loader!css-loader?modules&localIdentName=[path][name]---[local]---[hash:base64:5]'
use:['style-loader','css-loader']
},
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'file-loader',
options: {
esModule: false,
limit: 5 * 1024,
outputPath: "images",
}
}
]
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
}
},
{
test: /\.html$/,
// html中的img标签
use: ["html-withimg-loader"]
}
],
},
plugins:[
// 全局暴露统一入口
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
'window.jQuery': 'jquery',
}),
htmlTemplateIndex,
htmlTemplateProcess,
htmlTemplateFission,
new webpack.HotModuleReplacementPlugin(),
]
}
module.exports = dev