wjec-one 4.1.1 → 4.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/webpack.common.config.js +11 -13
- package/config/webpack.config.js +122 -63
- package/index.js +2 -2
- package/localization/index.js +1 -1
- package/package.json +2 -1
- package/umd/index.js +2 -2
- package/umd/localization/index.js +1 -1
|
@@ -25,8 +25,19 @@ module.exports = (_env, { mode }) => ({
|
|
|
25
25
|
}
|
|
26
26
|
}]
|
|
27
27
|
},
|
|
28
|
+
{
|
|
29
|
+
test: /(.*)\.favicon\.(ico|svg)$/,
|
|
30
|
+
use: {
|
|
31
|
+
loader: 'file-loader',
|
|
32
|
+
options: {
|
|
33
|
+
name: './[name].[ext]',
|
|
34
|
+
publicPath: '../'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
28
38
|
{
|
|
29
39
|
test: /\.svg$/,
|
|
40
|
+
exclude: /(.*)\.favicon\.svg$/,
|
|
30
41
|
use: [{
|
|
31
42
|
loader: '@svgr/webpack',
|
|
32
43
|
options: {
|
|
@@ -53,19 +64,6 @@ module.exports = (_env, { mode }) => ({
|
|
|
53
64
|
}
|
|
54
65
|
}]
|
|
55
66
|
},
|
|
56
|
-
{
|
|
57
|
-
type: 'javascript/auto',
|
|
58
|
-
test: /\.json$/,
|
|
59
|
-
include: /config/,
|
|
60
|
-
exclude: /node_modules/,
|
|
61
|
-
use: {
|
|
62
|
-
loader: 'file-loader',
|
|
63
|
-
options: {
|
|
64
|
-
name: './config/[name].json',
|
|
65
|
-
publicPath: '../'
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
67
|
{
|
|
70
68
|
test: /\.(ttf|eot|woff|woff2)$/,
|
|
71
69
|
use: {
|
package/config/webpack.config.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
const babelConfig = require('./babel.config');
|
|
1
2
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
2
3
|
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
3
4
|
const fs = require('fs');
|
|
5
|
+
const glob = require('glob');
|
|
4
6
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
5
7
|
const path = require('path');
|
|
6
8
|
const webpack = require('webpack');
|
|
@@ -14,79 +16,136 @@ const { overrides = {} } = require(path.join(appPath, 'package.json'));
|
|
|
14
16
|
const devServerHost = overrides.devServerHost || 'localhost';
|
|
15
17
|
const devServerPort = overrides.devServerPort === undefined ? 9001 : overrides.devServerPort;
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
const workerPathGlob = './!(node_modules|dist)/**/*.worker.@(js|ts)'.replaceAll(path.sep, path.posix.sep);
|
|
20
|
+
const workerPaths = glob.sync(workerPathGlob).reduce((workers, filePath) => {
|
|
21
|
+
const fileName = filePath.substring(filePath.lastIndexOf(path.sep) + 1, filePath.lastIndexOf('.'));
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
staticOptions: { redirect: false }
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
entry: { index: `${appPath}/index.tsx` },
|
|
23
|
+
return {
|
|
24
|
+
...workers,
|
|
25
|
+
[fileName]: `./${filePath}`
|
|
26
|
+
};
|
|
27
|
+
}, {});
|
|
28
|
+
|
|
29
|
+
const workerConfig = () => ({
|
|
30
|
+
extends: path.resolve(__dirname, './webpack.common.config.js'),
|
|
31
|
+
entry: workerPaths,
|
|
34
32
|
module: {
|
|
35
|
-
rules: [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
loader: 'file-loader',
|
|
42
|
-
options: {
|
|
43
|
-
name: `./config/${generateFilename('[name]', '.json')}`,
|
|
44
|
-
publicPath: '../'
|
|
45
|
-
}
|
|
33
|
+
rules: [
|
|
34
|
+
{
|
|
35
|
+
loader: 'babel-loader',
|
|
36
|
+
options: babelConfig,
|
|
37
|
+
test: /\.(js|jsx|mjs|ts|tsx)$/,
|
|
38
|
+
exclude: /core-js/
|
|
46
39
|
}
|
|
47
|
-
|
|
40
|
+
]
|
|
48
41
|
},
|
|
49
|
-
output: {
|
|
50
|
-
chunkFilename: generateFilename(),
|
|
51
|
-
filename: generateFilename(),
|
|
52
|
-
path: path.join(appPath, 'dist'),
|
|
53
|
-
publicPath: '/'
|
|
54
|
-
},
|
|
55
|
-
plugins: [
|
|
56
|
-
new CopyWebpackPlugin({
|
|
57
|
-
patterns: [
|
|
58
|
-
...fs.readdirSync(path.join(appPath, 'config')).map((fileName) => ({
|
|
59
|
-
from: path.join(appPath, 'config', fileName),
|
|
60
|
-
to: `config/${generateFilename('[name]', '.json')}`
|
|
61
|
-
}))
|
|
62
|
-
].filter(Boolean)
|
|
63
|
-
}),
|
|
64
|
-
new webpack.DefinePlugin({
|
|
65
|
-
'process.env.FILENAME_SUFFIX': JSON.stringify(getFilenameSuffix()),
|
|
66
|
-
'process.env.NODE_DEBUG': JSON.stringify(process.env.NODE_DEBUG),
|
|
67
|
-
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
|
|
68
|
-
}),
|
|
69
|
-
new ForkTsCheckerWebpackPlugin({
|
|
70
|
-
typescript: {
|
|
71
|
-
configFile: path.join(configPath, './tsconfig.json')
|
|
72
|
-
}
|
|
73
|
-
}),
|
|
74
|
-
new HtmlWebpackPlugin({
|
|
75
|
-
template: path.join(appPath, 'index.html'),
|
|
76
|
-
filename: './index.html',
|
|
77
|
-
tsconfig: path.join(configPath, './tsconfig.json')
|
|
78
|
-
})
|
|
79
|
-
],
|
|
80
42
|
resolve: {
|
|
81
|
-
fallback: {
|
|
82
|
-
stream: require.resolve('stream-browserify'),
|
|
83
|
-
process: require.resolve('process')
|
|
84
|
-
},
|
|
85
43
|
extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts', '.json'],
|
|
86
44
|
alias: {
|
|
87
45
|
config: path.join(appPath, 'config'),
|
|
88
46
|
src: path.join(appPath, 'src'),
|
|
89
47
|
test: path.join(appPath, 'test')
|
|
90
48
|
}
|
|
49
|
+
},
|
|
50
|
+
output: {
|
|
51
|
+
chunkFilename: generateFilename(),
|
|
52
|
+
filename: generateFilename(),
|
|
53
|
+
path: path.join(appPath, 'dist'),
|
|
54
|
+
publicPath: '/'
|
|
91
55
|
}
|
|
92
56
|
});
|
|
57
|
+
|
|
58
|
+
module.exports = () => ([
|
|
59
|
+
{
|
|
60
|
+
// Common config
|
|
61
|
+
extends: path.resolve(__dirname, './webpack.common.config.js'),
|
|
62
|
+
|
|
63
|
+
// Overrides
|
|
64
|
+
context: appPath,
|
|
65
|
+
devServer: {
|
|
66
|
+
host: devServerHost === 'localIp' ? '0.0.0.0' : devServerHost,
|
|
67
|
+
port: devServerPort,
|
|
68
|
+
historyApiFallback: true,
|
|
69
|
+
server: 'http',
|
|
70
|
+
static: {
|
|
71
|
+
directory: path.resolve(appPath, './'),
|
|
72
|
+
staticOptions: { redirect: false }
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
entry: { index: `${appPath}/index.tsx` },
|
|
76
|
+
module: {
|
|
77
|
+
rules: [
|
|
78
|
+
{
|
|
79
|
+
type: 'javascript/auto',
|
|
80
|
+
test: /\.json$/,
|
|
81
|
+
include: /config/,
|
|
82
|
+
exclude: /node_modules/,
|
|
83
|
+
use: {
|
|
84
|
+
loader: 'file-loader',
|
|
85
|
+
options: {
|
|
86
|
+
name: `./config/${generateFilename('[name]', '.json')}`,
|
|
87
|
+
publicPath: '../'
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
type: 'javascript/auto',
|
|
93
|
+
test: /\.worker\.(js|ts)$/,
|
|
94
|
+
exclude: /node_modules/,
|
|
95
|
+
use: {
|
|
96
|
+
loader: 'file-loader',
|
|
97
|
+
options: {
|
|
98
|
+
name: `./${generateFilename()}`,
|
|
99
|
+
publicPath: '',
|
|
100
|
+
emitFile: false
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
output: {
|
|
107
|
+
chunkFilename: generateFilename(),
|
|
108
|
+
filename: generateFilename(),
|
|
109
|
+
path: path.join(appPath, 'dist'),
|
|
110
|
+
publicPath: '/'
|
|
111
|
+
},
|
|
112
|
+
plugins: [
|
|
113
|
+
new CopyWebpackPlugin({
|
|
114
|
+
patterns: [
|
|
115
|
+
...fs.readdirSync(path.join(appPath, 'config')).map((fileName) => ({
|
|
116
|
+
from: path.join(appPath, 'config', fileName),
|
|
117
|
+
to: `config/${generateFilename('[name]', '.json')}`
|
|
118
|
+
}))
|
|
119
|
+
].filter(Boolean)
|
|
120
|
+
}),
|
|
121
|
+
new webpack.DefinePlugin({
|
|
122
|
+
'process.env.FILENAME_SUFFIX': JSON.stringify(getFilenameSuffix()),
|
|
123
|
+
'process.env.NODE_DEBUG': JSON.stringify(process.env.NODE_DEBUG),
|
|
124
|
+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
|
|
125
|
+
}),
|
|
126
|
+
new ForkTsCheckerWebpackPlugin({
|
|
127
|
+
typescript: {
|
|
128
|
+
configFile: path.join(configPath, './tsconfig.json')
|
|
129
|
+
}
|
|
130
|
+
}),
|
|
131
|
+
new HtmlWebpackPlugin({
|
|
132
|
+
template: path.join(appPath, 'index.html'),
|
|
133
|
+
filename: './index.html',
|
|
134
|
+
tsconfig: path.join(configPath, './tsconfig.json')
|
|
135
|
+
})
|
|
136
|
+
],
|
|
137
|
+
resolve: {
|
|
138
|
+
fallback: {
|
|
139
|
+
stream: require.resolve('stream-browserify'),
|
|
140
|
+
process: require.resolve('process')
|
|
141
|
+
},
|
|
142
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts', '.json'],
|
|
143
|
+
alias: {
|
|
144
|
+
config: path.join(appPath, 'config'),
|
|
145
|
+
src: path.join(appPath, 'src'),
|
|
146
|
+
test: path.join(appPath, 'test')
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
(workerPaths && Object.keys(workerPaths).length > 0) && workerConfig()
|
|
151
|
+
].filter(Boolean));
|