From 64471c649a723753ee03ba18eac6be34ed82060c Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Mon, 20 Nov 2017 00:59:28 +0200 Subject: [PATCH] Do not minify bundle.lib --- package.json | 2 +- webpack.config.ts | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 7c27b0ad..f2dceb46 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "cy:open": "cypress open", "bundle:clean": "rimraf bundles", "bundle:standalone": "webpack -p --env.lib --env.standalone --env.prod", - "bundle:lib": "webpack -p --env.lib --env.prod", + "bundle:lib": "webpack --env.lib", "bundle": "npm run bundle:clean && npm run bundle:lib && npm run bundle:standalone", "stats": "webpack -p --env.lib --env.standalone --env.prod --json --profile > stats.json", "prettier": "prettier --write \"src/**/*.{ts,tsx}\"" diff --git a/webpack.config.ts b/webpack.config.ts index adf230bf..6f258000 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -1,6 +1,10 @@ import * as webpack from 'webpack'; import * as HtmlWebpackPlugin from 'html-webpack-plugin'; -import * as nodeExternals from 'webpack-node-externals'; + +const nodeExternals = require('webpack-node-externals')({ + // bundle in moudules that need transpiling + non-js (e.g. css) + whitelist: ['swagger2openapi', 'reftools', /\.(?!(?:jsx?|json)$).{1,5}$/i], +}); export default env => { env = env || {}; @@ -105,10 +109,11 @@ export default env => { config.output!.libraryTarget = 'umd'; if (!env.standalone) { - config.externals = nodeExternals({ - // bundle in moudules that need transpiling + non-js (e.g. css) - whitelist: ['swagger2openapi', 'reftools', /\.(?!(?:jsx?|json)$).{1,5}$/i], - }); + config.externals = (context, request, callback) => { + // ignore node-fetch dep of swagger2openapi as it is not used + if (/node-fetch$/i.test(request)) return callback(null, 'var fetch'); + return nodeExternals(context, request, callback); + }; } } else { config.plugins!.push(