Disable dll plugin in storybook

This commit is contained in:
SleepWalker 2020-01-02 16:45:55 +02:00
parent 925a3a868e
commit 3cd2d21fce
2 changed files with 13 additions and 7 deletions

View File

@ -44,7 +44,7 @@
"build:quiet": "yarn run clean && yarn run build:webpack --quiet", "build:quiet": "yarn run clean && yarn run build:webpack --quiet",
"build:dll": "node ./packages/scripts/build-dll.js", "build:dll": "node ./packages/scripts/build-dll.js",
"build:serve": "http-server --proxy https://dev.account.ely.by ./build", "build:serve": "http-server --proxy https://dev.account.ely.by ./build",
"sb": "start-storybook -p 9009 --ci", "sb": "APP_ENV=storybook start-storybook -p 9009 --ci",
"build-storybook": "build-storybook" "build-storybook": "build-storybook"
}, },
"husky": { "husky": {

View File

@ -25,9 +25,11 @@ const isProduction = process.env.NODE_ENV === 'production';
const isAnalyze = process.argv.some(arg => arg === '--analyze'); const isAnalyze = process.argv.some(arg => arg === '--analyze');
const isDockerized = !!process.env.DOCKERIZED; const isDockerized = !!process.env.DOCKERIZED;
const isStorybook = process.env.APP_ENV === 'storybook';
const isCI = !!process.env.CI; const isCI = !!process.env.CI;
const isSilent = isCI || process.argv.some(arg => /quiet/.test(arg)); const isSilent = isCI || process.argv.some(arg => /quiet/.test(arg));
const isCspEnabled = false; const isCspEnabled = false;
const enableDll = !isProduction && !isStorybook;
process.env.NODE_ENV = isProduction ? 'production' : 'development'; process.env.NODE_ENV = isProduction ? 'production' : 'development';
@ -91,7 +93,7 @@ const webpackConfig = {
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
template: 'packages/app/index.ejs', template: 'packages/app/index.ejs',
favicon: 'packages/app/favicon.ico', favicon: 'packages/app/favicon.ico',
scripts: isProduction ? [] : ['/dll/vendor.dll.js'], scripts: enableDll ? ['/dll/vendor.dll.js'] : [],
hash: false, // webpack does this for all our assets automagically hash: false, // webpack does this for all our assets automagically
filename: 'index.html', filename: 'index.html',
inject: false, inject: false,
@ -281,12 +283,16 @@ if (isProduction) {
// this will improve build performance // this will improve build performance
// this mode will be default for dev builds in webpack 5 // this mode will be default for dev builds in webpack 5
new EagerImportsPlugin(), new EagerImportsPlugin(),
);
if (enableDll) {
webpackConfig.plugins.push(
new webpack.DllReferencePlugin({ new webpack.DllReferencePlugin({
context: __dirname, context: __dirname,
manifest: require('./dll/vendor.json'), manifest: require('./dll/vendor.json'),
}), }),
); );
}
webpackConfig.devServer = { webpackConfig.devServer = {
host: 'localhost', host: 'localhost',