forked from SwiftFiddle/swiftfiddle-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
113 lines (112 loc) · 2.76 KB
/
webpack.common.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
const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
const CopyWebbackPlugin = require("copy-webpack-plugin");
module.exports = {
entry: {
index: "./Public/index.js",
embedded: "./Public/embedded.js",
"editor.worker": "monaco-editor/esm/vs/editor/editor.worker.js",
},
output: {
globalObject: "self",
filename: "[name].[contenthash].js",
path: path.resolve(__dirname, "Public/dist"),
publicPath: "/",
clean: true,
},
module: {
rules: [
{
test: /\.scss$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: "css-loader",
options: {
url: false,
sourceMap: true,
importLoaders: 2,
},
},
{
loader: "postcss-loader",
options: {
sourceMap: true,
postcssOptions: {
plugins: ["autoprefixer"],
},
},
},
{
loader: "sass-loader",
options: {
sourceMap: true,
},
},
],
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: "asset/resource",
},
{
test: "/.worker.js$/",
loader: "worker-loader",
options: {
filename: "[name].[contenthash].worker.js",
},
},
],
},
plugins: [
new MiniCssExtractPlugin({
filename: "[name].[contenthash].css",
}),
new HtmlWebpackPlugin({
chunks: ["index"],
filename: "index.leaf",
template: "./Public/index.html",
}),
new HtmlWebpackPlugin({
chunks: ["embedded"],
filename: "embedded.leaf",
template: "./Public/embedded.html",
}),
new MonacoWebpackPlugin({
filename: "[name].[contenthash].worker.js",
languages: ["swift"],
}),
new CopyWebbackPlugin({
patterns: [
{ from: "./Public/images/*.*", to: "images/[name][ext]" },
{ from: "./Public/favicons/*.*", to: "[name][ext]" },
{ from: "./Public/error.html", to: "error.leaf" },
{ from: "./Public/robots.txt", to: "robots.txt" },
],
}),
],
optimization: {
splitChunks: {
cacheGroups: {
"monaco-editor": {
test: /[\\/]monaco-editor[\\/]/,
chunks: "initial",
name: "monaco-editor",
},
xterm: {
test: /[\\/]xterm[\\/]/,
chunks: "initial",
name: "xterm",
},
},
},
},
};