-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.dev.config.js
63 lines (61 loc) · 1.69 KB
/
webpack.dev.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
const path = require('path');
// 导入每次删除文件夹的插件
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const htmlWebpackPlugin = new HtmlWebpackPlugin({
template: path.join(__dirname, "./example/src/index.html"),
filename: "./index.html"
});
module.exports = {
entry: path.join(__dirname, "./example/src/app.js"),
output: {
path: path.join(__dirname, "example/dist"),
filename: "[name].bundle.js"
},
mode: 'development',
module: {
rules: [{
test: /\.(js|jsx)$/,
loader: "babel-loader",
exclude: [/node_modules/, '/lib/']
}, {
test: /\.scss$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
//如果需要,可以在 sass-loader 之前将 resolve-url-loader 链接进来
use: [
{
loader: 'css-loader',
options: {
modules: {
mode: 'local',
localIdentName: '[name]__[local]--[hash:base64:5]'
},
}
},
'sass-loader']
})
},
{
test: /\.(png|jpe?g|gif|bmp)$/i,
loader: 'url-loader',
options: {
limit: 10240,
name: 'images/[name]-[hash:8].[ext]'
},
},
]
},
plugins: [
new CleanWebpackPlugin(),
htmlWebpackPlugin,
new ExtractTextPlugin('style.css')
],
resolve: {
extensions: [".js", ".jsx"]
},
devServer: {
port: 3002
}
};