-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
46 lines (44 loc) · 1.47 KB
/
webpack.config.js
File metadata and controls
46 lines (44 loc) · 1.47 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
var path = require('path');
var htmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: path.join(__dirname, 'src/main.js'), //入口
output: {
path: path.join(__dirname, 'dist'), // 输出目录
filename: 'bundle.js' // 输出文件名
},
module: {
rules: [{
test: /\.css$/,
use: ['style-loader', 'css-loader']
// use: ['style-loader', {loader:'css-loader',options: { modules: true }}] 如何使用import加载网络上的css文件?
},
{
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'sass-loader']
},
{
test: /\.(png|gif|jpg|jpeg)$/,
use: 'url-loader'
},
{
// test: /\.(js|jsx)$/,
test: /\.js?$/,
use: 'babel-loader',
exclude: /node_modules/
}
]
},
// devServer: { // --open --port 3000 --hot devserver这里配置比较灵活,但我的无法打开
// open: true, // 自动打开浏览器
// port: 8080, // 指定端口号 //会打开8080sundefined
// hot: true, // 指定启用热更新
// inline: true
// },
plugins: [
new htmlWebpackPlugin({
template: path.join(__dirname, 'src/index.html'), // 指定模板
filename: 'index.html'
})
]
// 还是不行
}