From 155f2bb0e801bf621f3a2717a66b01cc16648116 Mon Sep 17 00:00:00 2001 From: Yury Shkoda Date: Wed, 9 Jun 2021 13:53:27 +0300 Subject: [PATCH] fix(webpack): removed process plugin from nodeConfig --- webpack.config.js | 49 +++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index cee7d79..730b819 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,19 +2,30 @@ const path = require('path') const webpack = require('webpack') const terserPlugin = require('terser-webpack-plugin') +const defaultPlugins = [ + new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en/), + new webpack.SourceMapDevToolPlugin({ + filename: null, + exclude: [/node_modules/], + test: /\.ts($|\?)/i + }) +] + +const optimization = { + minimize: true, + minimizer: [ + new terserPlugin({ + parallel: true, + terserOptions: {} + }) + ] +} + const browserConfig = { entry: './src/index.ts', devtool: 'inline-source-map', mode: 'production', - optimization: { - minimize: true, - minimizer: [ - new terserPlugin({ - parallel: true, - terserOptions: {} - }) - ] - }, + optimization: optimization, module: { rules: [ { @@ -35,20 +46,26 @@ const browserConfig = { library: 'SASjs' }, plugins: [ - new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en/), - new webpack.SourceMapDevToolPlugin({ - filename: null, - exclude: [/node_modules/], - test: /\.ts($|\?)/i - }), + ...defaultPlugins, new webpack.ProvidePlugin({ process: 'process/browser' }) ] } +const browserConfigWithoutProcessPlugin = { + entry: browserConfig.entry, + devtool: browserConfig.devtool, + mode: browserConfig.mode, + optimization: optimization, + module: browserConfig.module, + resolve: browserConfig.resolve, + output: browserConfig.output, + plugins: defaultPlugins +} + const nodeConfig = { - ...browserConfig, + ...browserConfigWithoutProcessPlugin, target: 'node', entry: './node/index.ts', output: {