Skip to content

Commit

Permalink
feat: generate unminified js?
Browse files Browse the repository at this point in the history
Fixes decaporg#6104 (if it works)
  • Loading branch information
mmkal committed Jan 21, 2022
1 parent bd4d99d commit e702eec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/netlify-cms-core/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ function configs() {
});
}

console.dir(configs(), {depth:100})

module.exports = configs();
15 changes: 13 additions & 2 deletions scripts/webpack.js
Original file line number Diff line number Diff line change
@@ -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');

Expand Down Expand Up @@ -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/,
}),
};
}

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()),
Expand All @@ -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',

Expand Down

0 comments on commit e702eec

Please sign in to comment.