-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.js
120 lines (116 loc) · 3.03 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
const webpack = require('webpack');
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const sourcePath = path.join(__dirname, './src');
const outPath = path.join(__dirname, './dist');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ENV_TYPE = {
DEV: 'development',
PRODUCTION: 'production',
};
module.exports = function(env) {
const mode = env.mode || ENV_TYPE.PRODUCTION;
return {
mode: mode,
context: sourcePath,
entry: {
main: './index.tsx',
},
output: {
path: outPath,
publicPath: '/',
filename: 'app.[hash].js',
},
devtool: 'source-map',
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
// Fix webpack's default behavior to not load packages with jsnext:main module
// https://github.com/Microsoft/TypeScript/issues/11677
mainFields: ['main'],
modules: [
sourcePath,
path.join(__dirname, 'node_modules')
]
},
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /(node_modules|ArachneUIComponents|@types)/gi,
loaders: ['ts-loader']
},
{
test: /\.jsx?$/,
exclude: /(node_modules|ArachneUIComponents)/,
loaders: ['babel-loader']
},
{
test: /\.scss$/,
use: [
{
loader: "style-loader"
},
{
loader: "css-loader"
},
{
loader: "sass-loader",
options: {
includePaths: [
sourcePath,
path.join(__dirname, 'node_modules')
],
data: "$isAppNode: false;"
},
},
]
}
]
},
devServer: {
contentBase: sourcePath,
historyApiFallback: true,
hot: true,
port: 3000,
stats: {
warnings: false
},
proxy: {
'/api': 'http://localhost:3010',
'/auth/sso': 'http://localhost:3010',
'/auth/slo': 'http://localhost:3010',
}
},
plugins: [
new HtmlWebpackPlugin({
inject: false,
hash: true,
template: 'index.html',
favicon: 'favicon.ico',
}),
new CopyWebpackPlugin([
{
from: path.join(__dirname, 'node_modules/arachne-ui-components/lib/resources/fonts'),
to: path.join(outPath, 'fonts')
},
{
from: path.join(__dirname, 'node_modules/arachne-ui-components/lib/resources/material-design-icons/iconfont'),
to: path.join(outPath, 'fonts')
},
{
from: path.join(__dirname, 'resources/icons'),
to: path.join(outPath, 'icons')
},
]),
new webpack.DefinePlugin({
__DEV__: mode === ENV_TYPE.DEV,
}),
],
node: {
// workaround for webpack-dev-server issue
// https://github.com/webpack/webpack-dev-server/issues/60#issuecomment-103411179
fs: 'empty',
net: 'empty'
}
};
}