-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.web.config.js
109 lines (108 loc) · 3.54 KB
/
webpack.web.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
const webpack = require("webpack");
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const HtmlWebpackTagsPlugin = require("html-webpack-tags-plugin");
const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const WorkboxPlugin = require("workbox-webpack-plugin");
module.exports = env => ({
entry: {
main: "./src/renderer/index.js",
pythonWorker: "./src/web/pythonWorker.js",
sqlWorker: "./src/languages/sql/web/sqlWorker.js",
webConsoleWorker: "./src/web/webConsole/webConsoleWorker.js",
},
output: {
filename: "static/[name].js",
path: path.resolve(__dirname, "dist/web/"),
globalObject: "this", // workaround for HMR, https://github.com/webpack/webpack/issues/6642
publicPath: "/",
},
devtool: "source-map",
devServer: {
contentBase: path.resolve(__dirname, "dist/web/static/"),
proxy: {
"/api": {
target: "http://localhost:5000",
secure: false,
},
},
},
module: {
noParse: /monaco-editor\/min\/vs\/loader\.js|jquery\.jsPlumb-1\.3\.10-all-min\.js/,
rules: [
{
test: /.jsx?$/,
loader: "babel-loader",
exclude: /node_modules/,
query: {
presets: ["@babel/react"],
},
},
{
test: /\.css$/,
use: [{ loader: "style-loader" }, { loader: "css-loader" }],
},
{
test: /\.(eot|woff|woff2|ttf|svg|png|jpe?g|gif)(\?\S*)?$/,
loader: "url-loader",
},
{
test: /\.py$/i,
use: "raw-loader",
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: "eslint-loader",
options: {
emitError: true,
emitWarning: true,
},
},
],
},
plugins: [
new HtmlWebpackPlugin({
title: "61A Code",
excludeChunks: ["pythonWorker", "webConsoleWorker", "sqlWorker"],
favicon: "./static/favicon.ico",
filename: "./static/index.html",
template: "./build/index.html",
}),
new HtmlWebpackTagsPlugin({ tags: ["static/pace/pace.min.js", "static/pace/pace.css"], append: false }),
new webpack.DefinePlugin({
ELECTRON: false,
SCHEME_COMPILE: env?.SCHEME_COMPILE || false,
__static: JSON.stringify("/static"),
VERSION: "\"2.0.9\"",
}),
new MonacoWebpackPlugin({
output: "./static",
languages: ["python", "scheme", "sql"],
}),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
jquery: "jquery",
}),
new CopyWebpackPlugin([{
from: "static",
to: "static",
ignore: ["IGNORE*"],
},
{
from: "src/web-server",
to: ".",
}]),
new WorkboxPlugin.GenerateSW({
swDest: "static/service-worker.js",
exclude: [/.*/],
importsDirectory: "static",
runtimeCaching: [{
urlPattern: ({ url }) => !url.pathname.match(/\/?(oauth|data).*/),
handler: "StaleWhileRevalidate",
}],
}),
],
});