forked from scratchfoundation/scratchjr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
72 lines (70 loc) · 2.23 KB
/
Copy pathwebpack.config.js
File metadata and controls
72 lines (70 loc) · 2.23 KB
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
const webpack = require("webpack");
const WebpackNotifierPlugin = require("webpack-notifier");
module.exports = (env, argv) => {
const isProduction = argv.mode === "production";
const assetBaseURL = isProduction
? "https://codehs.com/scratchjr_assets/"
: "http://localhost:8000/scratchjr_assets/";
return {
devtool: "source-map",
entry: {
app: "./src/entry/app.js",
},
output: {
publicPath: assetBaseURL,
path: __dirname + "/src/build/bundles",
filename: "[name].bundle.js",
},
performance: {
hints: false,
},
watchOptions: {
ignored: ["node_modules", "src/build/**/*"],
},
module: {
rules: [
{
test: /\.js$/,
include: /node_modules/,
loaders: ["strip-sourcemap-loader"],
},
{
loader: "babel-loader",
exclude: /node_modules/,
test: /\.jsx?$/,
query: {
presets: ["es2015", "stage-3"],
},
},
{
test: /\.wasm$/,
type: "javascript/auto",
},
],
},
plugins: [
new WebpackNotifierPlugin({
title: "ScratchJr",
alwaysNotify: true,
}),
// Define a global constant for asset URLs that can be used anywhere in the code
new webpack.DefinePlugin({
ASSET_BASE_URL: JSON.stringify(assetBaseURL),
}),
],
node: {
fs: "empty",
},
devServer: {
disableHostCheck: true,
// https://stackoverflow.com/questions/31602697/webpack-dev-server-cors-issue
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",
},
},
};
};