-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
141 lines (137 loc) · 3.54 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const JUPYTER_HOST = 'http://localhost:8888';
const IS_PRODUCTION = process.argv.indexOf('--mode=production') > -1;
const mode = IS_PRODUCTION ? "production" : "development";
const devtool = IS_PRODUCTION ? false : "inline-cheap-source-map";
const minimize = IS_PRODUCTION ? true : false;
const publicPath = IS_PRODUCTION ? "/static/jupyter_manager/" : "http://localhost:3063/";
module.exports = {
entry: "./src/ManagerApp",
mode: mode,
devServer: {
port: 3063,
client: { overlay: false },
historyApiFallback: true,
hot: !IS_PRODUCTION,
// static: path.join(__dirname, "dist"),
proxy: {
'/api/jupyter': {
target: JUPYTER_HOST,
ws: true,
secure: false,
changeOrigin: true,
},
},
},
watchOptions: {
aggregateTimeout: 300,
poll: 2000, // Seems to stabilise HMR file change detection
ignored: "/node_modules/"
},
devtool,
optimization: {
minimize,
// usedExports: true,
},
output: {
publicPath,
// filename: '[name].[contenthash].jupyter-manager.js',
filename: '[name].jupyter-manager.js',
},
resolve: {
extensions: [".ts", ".tsx", ".js", ".jsx"],
alias: {
path: "path-browserify",
stream: "stream-browserify",
},
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: "babel-loader",
options: {
plugins: [
"@babel/plugin-proposal-class-properties",
],
presets: [
["@babel/preset-react", {
runtime: 'automatic',
},
],
"@babel/preset-typescript",
],
cacheDirectory: true
},
exclude: /node_modules/,
},
{
test: /\.m?js$/,
resolve: {
fullySpecified: false,
},
},
{
test: /\.jsx?$/,
loader: "babel-loader",
options: {
presets: ["@babel/preset-react"],
cacheDirectory: true
}
},
{
test: /\.css?$/i,
use: ['style-loader', 'css-loader'],
},
{
// In .css files, svg is loaded as a data URI.
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
issuer: /\.css$/,
use: {
loader: 'svg-url-loader',
options: { encoding: 'none', limit: 10000 }
}
},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
issuer: /\.tsx$/,
use: [
'@svgr/webpack'
],
},
{
// In .ts and .tsx files (both of which compile to .js), svg files
// must be loaded as a raw string instead of data URIs.
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
issuer: /\.js$/,
use: {
loader: 'raw-loader'
}
},
{
test: /\.(png|jpg|jpeg|gif|ttf|woff|woff2|eot)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: [{ loader: 'url-loader', options: { limit: 10000 } }],
},
]
},
plugins: [
!IS_PRODUCTION ?
new webpack.ProvidePlugin({
process: 'process/browser'
})
:
new webpack.ProvidePlugin({
process: 'process/browser'
}),
new BundleAnalyzerPlugin({
analyzerMode: IS_PRODUCTION ? "static" : "disabled", // server, static, json, disabled.
openAnalyzer: false,
generateStatsFile: false,
}),
new HtmlWebpackPlugin({
template: "./public/index.html",
}),
],
};