This repository was archived by the owner on Aug 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.ts
More file actions
82 lines (79 loc) · 2.29 KB
/
webpack.config.ts
File metadata and controls
82 lines (79 loc) · 2.29 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
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
import * as path from 'path'
// Do not shorten following import, it will cause webpack.config file to not compile anymore
import { setup } from './src/auto-generated'
import * as webpack from 'webpack'
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
import HtmlWebpackPlugin from 'html-webpack-plugin'
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
// This line is required to get type's definition of 'devServer' attribute.
import 'webpack-dev-server'
const ROOT = path.resolve(__dirname, 'src/app')
const DESTINATION = path.resolve(__dirname, 'dist')
const webpackConfig: webpack.Configuration = {
context: ROOT,
mode: 'development',
entry: {
main: './main.ts',
},
experiments: {
topLevelAwait: true,
},
plugins: [
new MiniCssExtractPlugin({
filename: 'style.[contenthash].css',
insert: '#css-anchor',
}),
new HtmlWebpackPlugin({
template: './index.html',
filename: './index.html',
baseHref: `/applications/${setup.name}/${setup.version}/dist/`,
}),
new BundleAnalyzerPlugin({
analyzerMode: 'static',
reportFilename: './bundle-analysis.html',
openAnalyzer: false,
}),
],
output: {
filename: '[name].[contenthash].js',
path: DESTINATION,
},
resolve: {
extensions: ['.ts', '.js'],
modules: [ROOT, 'node_modules'],
},
externals: setup.externals,
module: {
rules: [
/****************
* PRE-LOADERS
*****************/
{
enforce: 'pre',
test: /\.js$/,
use: 'source-map-loader',
},
/****************
* LOADERS
*****************/
{
test: /\.ts$/,
exclude: [/node_modules/],
use: 'ts-loader',
},
{
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
],
},
devtool: 'source-map',
devServer: {
static: {
directory: path.join(__dirname, './'),
},
compress: true,
port: 3012,
},
}
export default webpackConfig