-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.common.js
103 lines (101 loc) · 2.61 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
const path = require("path");
const HtmlWebPackPlugin = require("html-webpack-plugin");
const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const package = require(path.resolve(__dirname, "./package.json"));
const webpack = require("webpack");
module.exports = {
entry: "./src/index.tsx",
context: __dirname,
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: [".ts", ".tsx", ".js", ".json"]
},
node: {
fs: "empty"
},
module: {
rules: [
// All files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'.
{
test: /\.tsx?$/,
use: [
{
// babel settings in in .babelrc file
loader: "babel-loader"
},
{
loader: "ts-loader"
}
]
},
{
test: /\.worker\.js$/,
use: { loader: "worker-loader" }
},
// local css loading
{
test: /\.css$/,
exclude: [/\.global.css$/, /node_modules/],
use: [
{
loader: "style-loader"
},
{
loader: "css-loader",
options: {
importLoader: 1,
modules: true,
localIdentName: "[name]__[local]"
}
}
]
},
// global css loading
{
test: /\global.css$/,
use: ["style-loader", "css-loader"]
},
// external css loading
{
test: /\.css$/,
include: [path.resolve(__dirname, "node_modules")],
use: ["style-loader", "css-loader"]
},
{
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/, /\.svg$/],
loader: require.resolve("url-loader"),
options: {
limit: 10000,
name: "static/media/[name].[hash:8].[ext]"
}
}
]
},
plugins: [
new HtmlWebPackPlugin({
template: "./src/index.html",
filename: "./index.html",
favicon: "src/favicon.ico"
}),
new MonacoWebpackPlugin({
languages: ["json", "javascript", "typescript"]
}),
new CopyWebpackPlugin([
{
from: "./node_modules/wasm-clingo/clingo.wasm",
to: "static/clingo.wasm"
}
]),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: "[name].css",
chunkFilename: "[id].css"
}),
new webpack.DefinePlugin({
VERSION: JSON.stringify(package.version)
})
]
};