1 |
|
2 |
|
3 | import * as webpack from 'webpack';
|
4 | import miniSVGDataURI from 'mini-svg-data-uri';
|
5 |
|
6 | const rules = [
|
7 | { test: /\.raw\.css$/, type: 'asset/source' },
|
8 | { test: /(?<!\.raw)\.css$/, use: ['style-loader', 'css-loader'] },
|
9 | { test: /\.txt$/, type: 'asset/source' },
|
10 | { test: /\.md$/, type: 'asset/source' },
|
11 | { test: /\.(jpg|png|gif)$/, type: 'asset/resource' },
|
12 | { test: /\.js.map$/, type: 'asset/resource' },
|
13 | {
|
14 | test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
|
15 | type: 'asset/resource'
|
16 | },
|
17 | {
|
18 | test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
|
19 | type: 'asset/resource'
|
20 | },
|
21 | {
|
22 | test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
|
23 | type: 'asset/resource'
|
24 | },
|
25 | { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, type: 'asset/resource' },
|
26 | {
|
27 |
|
28 | test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
|
29 | issuer: /\.css$/,
|
30 | type: 'asset',
|
31 | generator: {
|
32 | dataUrl: (content: any) => miniSVGDataURI(content.toString())
|
33 | }
|
34 | },
|
35 | {
|
36 |
|
37 |
|
38 | test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
|
39 | issuer: /\.js$/,
|
40 | type: 'asset/source'
|
41 | },
|
42 | {
|
43 | test: /\.m?js$/,
|
44 | type: 'javascript/auto'
|
45 | },
|
46 | {
|
47 | test: /\.m?js/,
|
48 | resolve: {
|
49 | fullySpecified: false
|
50 | }
|
51 | },
|
52 | {
|
53 | test: /\.c?js/,
|
54 | resolve: {
|
55 | fullySpecified: false
|
56 | }
|
57 | }
|
58 | ];
|
59 |
|
60 | const watch = process.argv.includes('--watch');
|
61 |
|
62 | module.exports = {
|
63 | bail: !watch,
|
64 | module: { rules },
|
65 | resolve: {
|
66 | fallback: {
|
67 | url: false,
|
68 | buffer: false,
|
69 | crypto: false,
|
70 |
|
71 | path: require.resolve('path-browserify'),
|
72 | process: require.resolve('process/browser')
|
73 | }
|
74 | },
|
75 | watchOptions: {
|
76 | poll: 500,
|
77 | aggregateTimeout: 1000
|
78 | },
|
79 | output: {
|
80 | hashFunction: 'sha256'
|
81 | },
|
82 | plugins: [
|
83 | new webpack.ProvidePlugin({
|
84 | process: 'process/browser'
|
85 | })
|
86 | ]
|
87 | };
|