diff options
author | Vitaly Takmazov | 2024-08-06 22:11:57 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2024-09-02 05:58:21 +0300 |
commit | 5a30741ef70d8a11e2f1976229957983f9c08fad (patch) | |
tree | 4b1543201435ed4027e05bf8e645718694c8fa94 /vnext/server | |
parent | 0149dddce3145875b45416cbc80bc229098fe495 (diff) |
Fix vnext server build
Diffstat (limited to 'vnext/server')
-rw-r--r-- | vnext/server/webpack.config.js | 59 |
1 files changed, 14 insertions, 45 deletions
diff --git a/vnext/server/webpack.config.js b/vnext/server/webpack.config.js index 9ffb3360..78c90050 100644 --- a/vnext/server/webpack.config.js +++ b/vnext/server/webpack.config.js @@ -1,21 +1,17 @@ -const ESLintPlugin = require('eslint-webpack-plugin') -const TerserPlugin = require('terser-webpack-plugin') +const nodeExternals = require('webpack-node-externals') +const path = require('path') -module.exports = () => { - 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, +module.exports = { + devtool: false, entry: { 'server': [ - __dirname + '/index.js' + path.resolve(__dirname, 'index.js') ] }, target: 'node', output: { - path: __dirname + '/../../public', - filename: '[name].js' + path: path.resolve(__dirname, '../../public'), + filename: '[name].js', }, module: { rules: [{ @@ -26,7 +22,8 @@ module.exports = () => { loader: 'babel-loader' }, { test: /\.(png|jpe?g|gif|svg)$/i, - type: 'asset/resource' + type: 'asset/resource', + dependency: { not: ['url'] }, }] }, plugins: [ @@ -34,37 +31,9 @@ module.exports = () => { 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: { - runtimeErrors: 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: {}, - }), - ] + }, + externalsPresets: { node: true }, // in order to ignore built-in modules like path, fs, etc. + externals: [nodeExternals({ + allowlist: [/\.(?!(?:jsx?|json)$).{1,5}$/i] + })], } - return config -} |