-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
81 lines (76 loc) · 2.21 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
/**
* @packageDocumentation Webpack configuration file.
* @author Blockly Team (https://github.com/google/blockly-samples/tree/master/examples/sample-app-ts)
* @author [email protected] (Sébastien Canet)
*/
const path = require("path");
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
// Base config that applies to either development or production mode.
let config = {
entry: "./src/index.ts",
output: {
// Compile the source files into a bundle.
filename: "bundle.js",
path: path.resolve(__dirname, "dist/bundle"),
clean: true,
},
// Enable webpack-dev-server to get hot refresh of the app.
devServer: {
static: "./build",
compress: true,
},
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
},
plugins: [
new webpack.optimize.ModuleConcatenationPlugin(),
new HtmlWebpackPlugin({
template: "public/index.html",
}),
new MonacoWebpackPlugin(),
new CopyPlugin({
patterns: [
{
from: path.resolve(__dirname, "./node_modules/blockly/media"),
to: path.resolve(__dirname, "docs/media"),
},
{
from: path.resolve(__dirname, "public"),
to: path.resolve(__dirname, "docs"),
},
],
}),
],
};
module.exports = (_env, argv) => {
if (argv.mode === "development") {
config.output.path = path.resolve(__dirname, "build");
config.devtool = "eval-cheap-module-source-map";
// Include the source maps for Blockly for easier debugging Blockly code.
config.module.rules.push({
test: /(blockly\/.*\.js)$/,
use: [require.resolve("source-map-loader")],
enforce: "pre",
});
// Ignore spurious warnings from source-map-loader
// It can't find source maps for some Closure modules and that is expected
config.ignoreWarnings = [/Failed to parse source map/];
}
return config;
};