-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.base.js
112 lines (100 loc) · 2.37 KB
/
webpack.config.base.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
"use strict";
import path from 'path';
export default {
// file-loader is deprecated for webpack v5
// webpack Asset Modules is the recommended solution
// see https://github.com/webpack-contrib/file-loader
// see https://webpack.js.org/guides/asset-modules/
module: {
rules: [
{
test: /robots\.txt$/,
// see https://webpack.js.org/guides/asset-modules/
type: 'asset/resource',
generator: {
// [ext] already contains the dot (.)
filename: '[name][ext]',
},
include: [
path.resolve(__dirname, 'app'),
],
},
{
test: /_(redirects|headers)$/,
// see https://webpack.js.org/guides/asset-modules/
type: 'asset/resource',
generator: {
filename: '[name]',
},
include: [
path.resolve(__dirname, 'app'),
],
},
{
test: /manifest.json$/,
// see https://webpack.js.org/guides/asset-modules/
type: 'asset/resource',
generator: {
// [ext] already contains the dot (.)
filename: '[name].[contenthash].imt[ext]',
},
use: [
'web-app-manifest-loader',
],
include: [
path.resolve(__dirname, 'app'),
],
},
// {
// test: /\.mjs$/,
// type: 'javascript/auto',
// },
{
test: /\.(ts|js)x?$/,
loader: 'babel-loader',
options: {
cacheDirectory: true,
},
include: [
path.resolve(__dirname, 'app'),
],
},
{
test: /\.(png|jpg|mp3)$/,
// see https://webpack.js.org/guides/asset-modules/
type: 'asset/resource',
generator: {
// [ext] already contains the dot (.)
filename: '[name].[contenthash].imt[ext]',
},
include: [
path.resolve(__dirname, 'app'),
],
},
],
},
// https://github.com/webpack/webpack/issues/11660
target: 'web', // default is browserslist
resolve: {
extensions: ['.ts', '.tsx', '.js'],
},
resolveLoader: {
modules: [
'node_modules',
path.resolve(__dirname, 'tools'),
],
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
// see https://webpack.js.org/configuration/output/#outputhashdigestlength
// hashDigestLength,
// see https://webpack.js.org/configuration/output/#outputhashfunction
// hashFunction,
},
plugins: [],
optimization: {
moduleIds: 'named',
// minimize: false, // (true by default for production) https://github.com/babel/minify probably does not work (outputs are even bigger)
},
};