-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
43 lines (41 loc) · 1.34 KB
/
webpack.common.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
const path = require('path');
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = {
entry: {
app: './src/index.js',
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [{
test: /\.(js|jsx)$/,
use:{
loader: 'babel-loader',
options: {
// This is a feature of `babel-loader` for webpack (not Babel itself).
// It enables caching results in ./node_modules/.cache/babel-loader/
// directory for faster rebuilds.
cacheDirectory: true,
plugins: ['react-hot-loader/babel'],
},
}
}, {
test: /\.(css|less)$/,
use: ['style-loader', 'css-loader', 'less-loader']
}]
},
plugins: [
new HtmlWebpackPlugin({
title: 'Output Management',
template: './public/index.html',//模板文件
favicon:'./public/favicon.ico'
}),
new CleanWebpackPlugin(['dist']), //清理dist旧的build文件
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin()
]
};