aboutsummaryrefslogtreecommitdiff
path: root/vnext
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2023-03-07 12:45:40 +0300
committerGravatar Vitaly Takmazov2023-03-07 12:45:40 +0300
commitb4ce703820264a7ed16b5b3efee973aadc43335d (patch)
tree95b820f6aaf49c0497c6141a2502be15cc365b47 /vnext
parentcfdb649ae18e25925dcc3c4acee6bc76754cc025 (diff)
build vnext server with webpack
Diffstat (limited to 'vnext')
-rw-r--r--vnext/server/webpack.config.js74
1 files changed, 74 insertions, 0 deletions
diff --git a/vnext/server/webpack.config.js b/vnext/server/webpack.config.js
new file mode 100644
index 00000000..a58f858c
--- /dev/null
+++ b/vnext/server/webpack.config.js
@@ -0,0 +1,74 @@
+/* eslint-disable @typescript-eslint/no-var-requires */
+
+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 ? 'cheap-module-source-map' : false,
+ entry: {
+ 'server': [
+ __dirname + '/index.js'
+ ]
+ },
+ target: 'node',
+ output: {
+ path: __dirname + '/../../public',
+ filename: '[name].js'
+ },
+ module: {
+ rules: [{
+ test: /\.js$/,
+ exclude: [
+ /node_modules/
+ ],
+ 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.devServer = {
+ hot: true,
+ historyApiFallback: true,
+ client: {
+ overlay: true
+ }
+ };
+ }
+ 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;
+};