aboutsummaryrefslogtreecommitdiff
path: root/vnext
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2023-03-06 08:29:48 +0300
committerGravatar Vitaly Takmazov2023-03-06 08:29:48 +0300
commit7f7d6dcbc7fbce6ff6c9171823ebe7a78604e85d (patch)
treee3a8f0da3765b123d918c1a4b4f1a9dead89cdb0 /vnext
parentbd7776515e26d27288093986881735376355c52c (diff)
vnext: esbuild -> webpack
Diffstat (limited to 'vnext')
-rw-r--r--vnext/webpack.config.js66
1 files changed, 66 insertions, 0 deletions
diff --git a/vnext/webpack.config.js b/vnext/webpack.config.js
new file mode 100644
index 00000000..d8b7a076
--- /dev/null
+++ b/vnext/webpack.config.js
@@ -0,0 +1,66 @@
+const ESLintPlugin = require('eslint-webpack-plugin');
+const TerserPlugin = require('terser-webpack-plugin');
+
+module.exports = (env, argv) => {
+ const node_env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
+ const dev = node_env !== 'production';
+ const config = {
+ mode: node_env,
+ devtool: dev ? 'source-map' : false,
+ entry: {
+ 'scripts': [
+ __dirname + '/src/index.js'
+ ]
+ },
+ output: {
+ path: __dirname + '/../public',
+ filename: '[name].js'
+ },
+ module: {
+ rules: [{
+ test: /\.js$/,
+ exclude: [
+ /\bnode_modules\b/,
+ /\bcore-js\b/,
+ /\bwebpack\/buildin\b/
+ ],
+ loader: 'babel-loader'
+ }, {
+ test: /\.(png|jpe?g|gif|svg)$/i,
+ use: [
+ {
+ loader: 'file-loader',
+ },
+ ],
+ }]
+ },
+ plugins: [
+ ],
+ resolve: {
+ symlinks: false,
+ extensions: ['.js']
+ }
+ };
+ if (dev) {
+ config.plugins.push(
+ new ESLintPlugin({
+ files: __dirname + '/src',
+ lintDirtyModulesOnly: true,
+ failOnWarning: false,
+ failOnError: true,
+ fix: false
+ }));
+ }
+ config.optimization = {
+ minimize: !dev,
+ minimizer: [
+ new TerserPlugin({
+ minify: TerserPlugin.swcMinify,
+ // `terserOptions` options will be passed to `swc` (`@swc/core`)
+ // Link to options - https://swc.rs/docs/config-js-minify
+ terserOptions: {},
+ }),
+ ]
+ };
+ return config;
+};