-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.mjs
More file actions
51 lines (50 loc) · 1.89 KB
/
webpack.config.mjs
File metadata and controls
51 lines (50 loc) · 1.89 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
import { resolve as resolvePath } from "node:path";
import webpack from "webpack";
import HtmlWebpackPlugin from "html-webpack-plugin";
import MiniCssExtractPlugin from "mini-css-extract-plugin";
export default function(env, argv) {
return {
entry: [resolvePath('.', 'src', 'main', 'ts', 'script.ts'), resolvePath('.', 'src', 'main', 'scss', 'index.scss')],
mode: env.production ? 'production' : 'development',
devtool: env.production ? 'source-map' : 'eval-source-map',
module: {
rules: [
{
test: /\.tsx?$/,
use: [
{
loader: 'ts-loader',
options: { configFile: resolvePath('.', 'config', env.production ? 'tsconfig.dist.json' : 'tsconfig.dev.json') }
}
],
exclude: /node_modules/,
},
{
test: /\.s[a|c]ss$/,
use: [env.production ? MiniCssExtractPlugin.loader : 'style-loader', 'css-loader', 'sass-loader']
}
],
},
devServer: {
static: {
directory: resolvePath('.', 'build')
},
compress: true,
port: 9908
},
resolve: { extensions: ['.tsx', '.ts', '.js'], },
output: {
filename: env.production ? 'index.bundle.min.mjs' : 'index.bundle.mjs',
path: resolvePath('.', 'build'),
clean: true
},
plugins: [
new MiniCssExtractPlugin({ filename: "index.min.css" }),
new HtmlWebpackPlugin({
scriptLoading: 'module',
template: resolvePath('.', 'src', 'main', 'html', 'index.html')
}),
new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery" })
]
}
};