-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathwebpack.config.js
76 lines (67 loc) · 1.94 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const ReplaceInFileWebpackPlugin = require('replace-in-file-webpack-plugin');
const {EnvironmentPlugin} = require("webpack");
// require('dotenv').config();
const isProduction = (process.env.NODE_ENV && (process.env.NODE_ENV == 'production'));
// webpack.config.js
module.exports = {
mode: isProduction ? 'production' : 'development',
entry: {
app: [
'./index.js'
]
},
output: {
filename: '[name].js',
},
module: {
rules: [
{
test: /\.elm$/,
exclude: [/elm-stuff/, /node_modules/, /build/],
use: [
{
loader: isProduction ? 'elm-webpack-loader?optimize=true' : 'elm-webpack-loader'
}
]
},
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader' ]
}
]
},
plugins: [
new EnvironmentPlugin(["NODE_ENV"]),
new ReplaceInFileWebpackPlugin([{
files: ['app.js'],
rules: [
{
search: /\/\/-\/\//ig,
// search: '//-//',
replace: ''
},
{
search: /.\.contextAttributes\)\);return ./,
replace: function(match) {
const firstLetter = match[0];
const lastLetter = match[match.length - 1];
return firstLetter + '.contextAttributes));' + lastLetter + '.getExtension(\'OES_standard_derivatives\');return ' + lastLetter;
}
}
]
}])
],
devServer: {
inline: true,
// public: 'code2art.labs.jb.gg',
stats: { colors: true },
disableHostCheck: true,
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"
}
// host: '0.0.0.0',
// port: 80
}
};