-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.ts
More file actions
57 lines (54 loc) · 1.29 KB
/
webpack.config.ts
File metadata and controls
57 lines (54 loc) · 1.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
import * as path from 'path'
import * as fs from 'fs'
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
import * as webpack from 'webpack'
// get all view entrypoints
const views = fs.readdirSync(path.resolve(__dirname, 'source/views'))
const config: webpack.Configuration = {
mode: 'production',
entry: {
app: path.resolve(__dirname, 'source/app.ts'),
// reduce view entry points
...views.reduce(
(output, viewFileName) =>
viewFileName.split('.')[1] === 'ts'
? {
...output,
[viewFileName.split('.')[0]]: path.resolve(__dirname, 'source/views', viewFileName),
}
: output,
{}
),
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].bundle.js',
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
plugins: [
new MiniCssExtractPlugin({
filename: 'styles.css',
}),
],
module: {
rules: [
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.(ttf)(\?[\s\S]+)?$/,
loader: 'file-loader',
options: { name: '[name].[ext]' },
},
],
},
}
export default config