-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
48 lines (46 loc) · 1.13 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
const path = require('path')
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
mode: 'development',//production
entry: {
index: "./src/index.js",
},// 项目的入口文件,路径相对于项目的根路径
// 配置输出信息
output: {
//编译后的入口文件(别人用你的包的时候,引用的文件的名字,一般都是index.js
filename: 'index.js',
//编译后的文件将被输出到哪个文件夹下 这里是当前项目目录下的build里面
path: path.join(__dirname, 'build'),
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /(node_modules|build)/,
use: "babel-loader",
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"]
},
]
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, "./public/index.html"),
filename: "index.html",
}),
],
resolve: {// 扩展名
extensions: [".js", ".jsx"]
},
devServer: {
port: 3001,
open: true,
hot: true
},
// externals: {
// 'react': 'react',
// 'react-dom': 'react-dom',
// },
}