@dg-scripts/webpack-template 5.17.0
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/.babelrc.json +7 -0
- package/.prettierrc.json +9 -0
- package/.stylelintrc.json +3 -0
- package/.test.env +1 -0
- package/CHANGELOG.md +384 -0
- package/LICENSE +21 -0
- package/README.md +60 -0
- package/eslint.config.mjs +1 -0
- package/index.d.ts +60 -0
- package/jest.config.js +39 -0
- package/jest.env.setup.js +6 -0
- package/jest.setup.js +21 -0
- package/package.json +97 -0
- package/postcss.config.js +14 -0
- package/scripts/badge.ts +77 -0
- package/src/index.css +30 -0
- package/src/index.html +18 -0
- package/src/index.ts +5 -0
- package/src/particle/ExplodingParticle.ts +94 -0
- package/src/particle/ParticleFactory.ts +25 -0
- package/src/particle/ParticleSystem.ts +120 -0
- package/src/particle/__tests__/ExplodingParticle.test.ts +114 -0
- package/src/particle/__tests__/ParticleFactory.test.ts +30 -0
- package/src/particle/index.ts +1 -0
- package/tsconfig.json +38 -0
- package/webpack.config.js +235 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
const path = require('node:path')
|
|
2
|
+
const process = require('node:process')
|
|
3
|
+
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
|
4
|
+
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
|
5
|
+
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
|
|
6
|
+
const TerserPlugin = require('terser-webpack-plugin')
|
|
7
|
+
const StyleLintPlugin = require('stylelint-webpack-plugin')
|
|
8
|
+
const ESLintPlugin = require('eslint-webpack-plugin')
|
|
9
|
+
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
|
|
10
|
+
const WebpackBar = require('webpackbar')
|
|
11
|
+
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin')
|
|
12
|
+
|
|
13
|
+
const pkg = require('./package.json')
|
|
14
|
+
|
|
15
|
+
const isEnvDevelopment = process.env.NODE_ENV === 'development'
|
|
16
|
+
const isEnvProduction = process.env.NODE_ENV === 'production'
|
|
17
|
+
const isEnvProductionProfile
|
|
18
|
+
= isEnvProduction && process.argv.includes('--profile')
|
|
19
|
+
const useSass = Boolean(pkg.devDependencies.sass)
|
|
20
|
+
const enableAnalyzer = process.env.ANALYZE === 'true'
|
|
21
|
+
const imageInlineSizeLimit = Number.parseInt(
|
|
22
|
+
process.env.IMAGE_INLINE_SIZE_LIMIT || '10000',
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
/** @type {import('webpack').Configuration} */
|
|
26
|
+
module.exports = {
|
|
27
|
+
entry: {
|
|
28
|
+
main: './src/index.ts',
|
|
29
|
+
},
|
|
30
|
+
output: {
|
|
31
|
+
filename: isEnvDevelopment ? '[name].js' : '[name].[contenthash].js',
|
|
32
|
+
path: path.resolve(__dirname, 'dist'),
|
|
33
|
+
clean: true,
|
|
34
|
+
},
|
|
35
|
+
mode: isEnvDevelopment ? 'development' : 'production',
|
|
36
|
+
devServer: {
|
|
37
|
+
static: path.resolve(__dirname, 'dist'),
|
|
38
|
+
hot: true,
|
|
39
|
+
open: true,
|
|
40
|
+
port: 2333,
|
|
41
|
+
watchFiles: ['src/**/*.{html,ts,tsx,js,jsx}'],
|
|
42
|
+
},
|
|
43
|
+
module: {
|
|
44
|
+
rules: [
|
|
45
|
+
{
|
|
46
|
+
test: /\.tsx?$/,
|
|
47
|
+
exclude: /node_modules/,
|
|
48
|
+
use: ['ts-loader'],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
test: /\.(js|jsx)$/,
|
|
52
|
+
exclude: /node_modules/,
|
|
53
|
+
use: ['babel-loader'],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
test: /\.html$/,
|
|
57
|
+
exclude: /node_modules/,
|
|
58
|
+
use: [
|
|
59
|
+
{
|
|
60
|
+
loader: 'html-loader',
|
|
61
|
+
options: {
|
|
62
|
+
minimize: isEnvProduction,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
test: /\.(css|scss)$/,
|
|
69
|
+
exclude: /node_modules/,
|
|
70
|
+
use: [
|
|
71
|
+
isEnvDevelopment ? 'style-loader' : MiniCssExtractPlugin.loader,
|
|
72
|
+
{
|
|
73
|
+
loader: 'css-loader',
|
|
74
|
+
options: {
|
|
75
|
+
modules: true,
|
|
76
|
+
importLoaders: useSass ? 2 : 1,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
'postcss-loader',
|
|
80
|
+
useSass && 'sass-loader',
|
|
81
|
+
].filter(Boolean),
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
test: [/\.avif$/],
|
|
85
|
+
exclude: /node_modules/,
|
|
86
|
+
type: 'asset',
|
|
87
|
+
mimetype: 'image/avif',
|
|
88
|
+
parser: {
|
|
89
|
+
dataUrlCondition: {
|
|
90
|
+
maxSize: imageInlineSizeLimit,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
|
|
96
|
+
exclude: /node_modules/,
|
|
97
|
+
type: 'asset',
|
|
98
|
+
parser: {
|
|
99
|
+
dataUrlCondition: {
|
|
100
|
+
maxSize: imageInlineSizeLimit,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
test: /\.svg$/,
|
|
106
|
+
exclude: /node_modules/,
|
|
107
|
+
use: [
|
|
108
|
+
{
|
|
109
|
+
loader: require.resolve('@svgr/webpack'),
|
|
110
|
+
options: {
|
|
111
|
+
prettier: false,
|
|
112
|
+
svgo: false,
|
|
113
|
+
svgoConfig: {
|
|
114
|
+
plugins: [
|
|
115
|
+
{
|
|
116
|
+
name: 'preset-default',
|
|
117
|
+
params: {
|
|
118
|
+
overrides: {
|
|
119
|
+
removeViewBox: false,
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
titleProp: true,
|
|
126
|
+
ref: true,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
issuer: {
|
|
131
|
+
and: [/\.(ts|tsx|js|jsx|md|mdx)$/],
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
test: /\.woff2?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
|
|
136
|
+
exclude: /node_modules/,
|
|
137
|
+
use: 'url-loader?limit=10000',
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
test: /\.(ttf|eot)(\?[\s\S]+)?$/,
|
|
141
|
+
exclude: /node_modules/,
|
|
142
|
+
use: 'file-loader',
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
plugins: [
|
|
147
|
+
new HtmlWebpackPlugin({
|
|
148
|
+
template: './src/index.html',
|
|
149
|
+
}),
|
|
150
|
+
new MiniCssExtractPlugin({
|
|
151
|
+
filename: isEnvDevelopment ? '[name].css' : '[name].[contenthash].css',
|
|
152
|
+
chunkFilename: isEnvDevelopment ? '[id].css' : '[id].[contenthash].css',
|
|
153
|
+
}),
|
|
154
|
+
new StyleLintPlugin({
|
|
155
|
+
exclude: ['node_modules', 'build', 'dist', 'coverage'],
|
|
156
|
+
}),
|
|
157
|
+
new ESLintPlugin({
|
|
158
|
+
extensions: ['tsx', 'ts', 'jsx', 'js'],
|
|
159
|
+
configType: 'flat',
|
|
160
|
+
eslintPath: 'eslint/use-at-your-own-risk',
|
|
161
|
+
}),
|
|
162
|
+
enableAnalyzer && new BundleAnalyzerPlugin({ analyzerMode: 'static' }),
|
|
163
|
+
new WebpackBar(),
|
|
164
|
+
].filter(Boolean),
|
|
165
|
+
optimization: {
|
|
166
|
+
minimize: isEnvProduction,
|
|
167
|
+
minimizer: [
|
|
168
|
+
new TerserPlugin({
|
|
169
|
+
parallel: true,
|
|
170
|
+
terserOptions: {
|
|
171
|
+
parse: {
|
|
172
|
+
ecma: 8,
|
|
173
|
+
},
|
|
174
|
+
compress: {
|
|
175
|
+
ecma: 5,
|
|
176
|
+
warnings: false,
|
|
177
|
+
drop_console: true,
|
|
178
|
+
comparisons: false,
|
|
179
|
+
inline: 2,
|
|
180
|
+
keep_classnames: isEnvProductionProfile,
|
|
181
|
+
keep_fnames: isEnvProductionProfile,
|
|
182
|
+
},
|
|
183
|
+
mangle: {
|
|
184
|
+
safari10: true,
|
|
185
|
+
},
|
|
186
|
+
output: {
|
|
187
|
+
ecma: 5,
|
|
188
|
+
comments: false,
|
|
189
|
+
ascii_only: true,
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
}),
|
|
193
|
+
new CssMinimizerPlugin(),
|
|
194
|
+
],
|
|
195
|
+
splitChunks: {
|
|
196
|
+
chunks: 'async',
|
|
197
|
+
minSize: 30000,
|
|
198
|
+
minChunks: 1,
|
|
199
|
+
maxAsyncRequests: 6,
|
|
200
|
+
maxInitialRequests: 4,
|
|
201
|
+
automaticNameDelimiter: '-',
|
|
202
|
+
cacheGroups: {
|
|
203
|
+
vendors: {
|
|
204
|
+
name: 'chunk-vendors',
|
|
205
|
+
priority: -10,
|
|
206
|
+
chunks: 'initial',
|
|
207
|
+
test: /[\\/]node_modules[\\/]/,
|
|
208
|
+
},
|
|
209
|
+
common: {
|
|
210
|
+
name: 'chunk-common',
|
|
211
|
+
priority: -20,
|
|
212
|
+
chunks: 'initial',
|
|
213
|
+
minChunks: 2,
|
|
214
|
+
reuseExistingChunk: true,
|
|
215
|
+
},
|
|
216
|
+
particle: {
|
|
217
|
+
name: 'particle',
|
|
218
|
+
priority: 0,
|
|
219
|
+
chunks: 'all',
|
|
220
|
+
test: /[\\/]particle[\\/]/,
|
|
221
|
+
enforce: true,
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
resolve: {
|
|
227
|
+
extensions: ['.tsx', '.ts', '.jsx', '.js'],
|
|
228
|
+
plugins: [new TsconfigPathsPlugin({ configFile: './tsconfig.json' })],
|
|
229
|
+
},
|
|
230
|
+
cache: {
|
|
231
|
+
type: 'filesystem',
|
|
232
|
+
},
|
|
233
|
+
devtool: isEnvDevelopment ? 'eval-cheap-module-source-map' : false,
|
|
234
|
+
stats: 'errors-warnings',
|
|
235
|
+
}
|