-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathwebpack.config.ts
70 lines (66 loc) · 1.84 KB
/
webpack.config.ts
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
import CopyWebpackPlugin from "copy-webpack-plugin";
import HtmlWebpackPlugin from "html-webpack-plugin";
import sysPath from "path";
import ScriptExtPlugin from "script-ext-html-webpack-plugin";
import webpack from "webpack";
const PROJECT_ROOT: string = __dirname;
const files: ReadonlyArray<string> = [
"index",
"homestuck-beta",
"homestuck-beta2",
"squares",
"morph",
"shumway-3",
];
const config: webpack.Configuration = {
entry: [
sysPath.resolve(PROJECT_ROOT, "src", "main.browser.ts"),
],
output: {
path: sysPath.resolve(PROJECT_ROOT, "build", "browser", "scripts"),
filename: "[name].js",
},
resolve: {
extensions: [".js", ".json", ".ts"],
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
loader: "ts-loader",
options: {
configFile: "browser.tsconfig.json",
onlyCompileBundledFiles: true,
// visualStudioErrorFormat: true,
compilerOptions: {
declaration: false,
},
},
},
],
},
target: "web",
plugins: [
...files.map((name: string): webpack.Plugin => {
return new HtmlWebpackPlugin({
template: sysPath.resolve(PROJECT_ROOT, "src", "static", `${name}.html`),
filename: sysPath.resolve(PROJECT_ROOT, "build", "browser", `${name}.html`),
inject: "head",
});
}),
new ScriptExtPlugin({
defaultAttribute: "async",
}) as webpack.Plugin,
new CopyWebpackPlugin([
{
from: sysPath.resolve(PROJECT_ROOT, "src", "static", "**", "*.{gif,ico,jpg,png,svg,swf,css,js}"),
to: sysPath.resolve(PROJECT_ROOT, "build", "browser"),
context: sysPath.resolve(PROJECT_ROOT, "src", "static"),
ignore: ["index.html"],
},
]),
],
};
// tslint:disable-next-line:no-default-export
export default config;