Fix bundles

This commit is contained in:
Roman Hotsiy 2017-11-19 23:59:25 +02:00
parent f7374caf3c
commit bab7ce9f84
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
2 changed files with 11 additions and 9 deletions

View File

@ -11,7 +11,7 @@
"dev": "webpack-dashboard -- webpack-dev-server --hot",
"test": "npm run unit && npm run e2e",
"unit": "jest",
"e2e": "npm run e2e:tsc && cypress run",
"e2e": "npm run e2e:clean && npm run e2e:tsc && cypress run",
"e2e:tsc": "tsc -p tsconfig.e2e.json",
"e2e:clean": "rimraf e2e/.build",
"cy:open": "cypress open",
@ -19,7 +19,7 @@
"bundle:standalone": "webpack -p --env.lib --env.standalone --env.prod",
"bundle:lib": "webpack -p --env.lib --env.prod",
"bundle": "npm run bundle:clean && npm run bundle:lib && npm run bundle:standalone",
"stats": "webpack -p --env.prod --json --profile > stats.json",
"stats": "webpack -p --env.lib --env.standalone --env.prod --json --profile > stats.json",
"prettier": "prettier --write \"src/**/*.{ts,tsx}\""
},
"author": "",

View File

@ -7,7 +7,7 @@ export default env => {
let entry;
if (env.bundle) {
if (env.lib) {
entry = env.standalone ? ['./src/polyfills.ts', './src/standalone.tsx'] : './src/index.ts';
} else {
// playground or performance test
@ -25,7 +25,7 @@ export default env => {
entry: entry,
output: {
filename: env.standalone ? 'redoc.standalone.js' : 'redoc.lib.js',
path: __dirname + (env.bundle ? '/bundles' : 'lib'),
path: __dirname + (env.lib ? '/bundles' : 'lib'),
},
devServer: {
@ -101,13 +101,15 @@ export default env => {
}
if (env.lib) {
config.externals = nodeExternals({
// bundle in moudules that need transpiling + non-js (e.g. css)
whitelist: ['swagger2openapi', 'reftools', /\.(?!(?:jsx?|json)$).{1,5}$/i],
});
config.output!.library = 'Redoc';
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],
});
}
} else {
config.plugins!.push(
new HtmlWebpackPlugin({