-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathwebpack.config.js
62 lines (60 loc) · 1.49 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
54
55
56
57
58
59
60
61
62
const path = require('path');
const webpack = require('webpack');
const package = require('./package.json');
const isProd = process.env.NODE_ENV === 'production';
const publicPath = isProd ? package.panelServingUrl : 'http://0.0.0.0:8080/';
const buildPath = path.resolve(__dirname, 'dist');
module.exports = {
mode: isProd ? 'production' : 'development',
entry: './src/index.js',
resolve: {
alias: {
react: path.resolve('./node_modules/react'),
'@emotion/react': path.resolve('./node_modules/@emotion/react')
}
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
},
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(gif|png|jpe?g|svg)$/i,
use: ['url-loader']
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: ['file-loader']
}
],
},
plugins: [
new webpack.DefinePlugin({
__PUBLIC_PATH__: JSON.stringify(publicPath),
}),
],
output: {
filename: '[name].js',
chunkFilename: '[name].chunk.js',
path: buildPath,
publicPath,
},
devServer: {
contentBase: buildPath,
host: '0.0.0.0',
port: 8080,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
}
}
}