From e702eecb1aa2f7228370acbda10e2bd59d00e3e5 Mon Sep 17 00:00:00 2001 From: Misha Kaletsky Date: Fri, 21 Jan 2022 10:09:03 -0500 Subject: [PATCH] feat: generate unminified js? Fixes #6104 (if it works) --- packages/netlify-cms-core/webpack.config.js | 2 ++ scripts/webpack.js | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/netlify-cms-core/webpack.config.js b/packages/netlify-cms-core/webpack.config.js index 6dc835fac9aa..c47f3654a631 100644 --- a/packages/netlify-cms-core/webpack.config.js +++ b/packages/netlify-cms-core/webpack.config.js @@ -18,4 +18,6 @@ function configs() { }); } +console.dir(configs(), {depth:100}) + module.exports = configs(); diff --git a/scripts/webpack.js b/scripts/webpack.js index d3a1b9fca739..7c6c9bb29a28 100644 --- a/scripts/webpack.js +++ b/scripts/webpack.js @@ -1,5 +1,6 @@ const path = require('path'); const webpack = require('webpack'); +const TerserPlugin = require("terser-webpack-plugin"); const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin'); const { flatMap } = require('lodash'); @@ -47,6 +48,9 @@ function plugins() { ignoreEsprima: () => new webpack.IgnorePlugin(/^esprima$/, /js-yaml/), ignoreMomentOptionalDeps: () => new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), friendlyErrors: () => new FriendlyErrorsWebpackPlugin(), + terser: () => new TerserPlugin({ + exclude: /unminified/, + }), }; } @@ -79,12 +83,13 @@ function targetOutputs() { return { umd: { path: umdPath, - filename: `${pkg.name}.js`, + filename: `${pkg.name}.[name].js`, library: toGlobalName(pkg.name), libraryTarget: 'umd', libraryExport: toGlobalName(pkg.name), umdNamedDefine: true, globalObject: 'window', + chunkFilename: `${pkg.name}.[name].[id].[chunkhash].js` }, umddir: { path: umdDirPath, @@ -119,7 +124,10 @@ function baseConfig({ target = isProduction ? 'umd' : 'umddir' } = {}) { return { context: process.cwd(), mode: isProduction ? 'production' : 'development', - entry: './src', + entry: { + bundle: './src', + 'bundle.unminified': './src', + }, output: targetOutputs()[target], module: { rules: flatMap(Object.values(rules()), rule => rule()), @@ -131,6 +139,9 @@ function baseConfig({ target = isProduction ? 'umd' : 'umddir' } = {}) { }, }, plugins: Object.values(plugins()).map(plugin => plugin()), + optimization: { + minimizer: [plugins().terser()], + }, devtool: isTest ? '' : 'source-map', target: 'web',