-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwebpack.config.js
53 lines (49 loc) · 1.1 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
/**
* @authors ZiQiangWang
* @email [email protected]
* @date 2017-08-04 16:03:13
*/
var path = require('path');
var webpack = require('webpack');
var htmlWebpackPlugin = require('html-webpack-plugin');
// 定义路径
const PATHS = {
root: path.resolve(__dirname),
src: path.resolve(__dirname, 'src'),
dist: path.resolve(__dirname, 'dist'),
node_modules: path.resolve(__dirname, 'node_modules')
};
module.exports = {
entry: './src/index',
output: {
path: PATHS.dist,
filename: 'js/[name].bundle.js'
},
module: {
rules: [
{
test: /\.jsx$/,
use: ['babel-loader'],
exclude: PATHS.node_modules,
include: PATHS.src,
},
{
test: /\.js$/,
use: ['babel-loader'],
exclude: PATHS.node_modules,
include: PATHS.src,
}
]
},
plugins: [
// html文件导出,这里的将文件导出到根目录
new htmlWebpackPlugin({
template: './src/index.html',
filename: 'index.html',
inject: 'body',
})
],
resolve: {
extensions: ['.js','.jsx'] //后缀名自动补全
}
}