Skip to content

Commit

Permalink
Merge pull request #5238 from storybooks/fix/dll
Browse files Browse the repository at this point in the history
ADD a `no-dll` option to CLI to disable DllReferencePlugin, fix polyfills missing in manager
  • Loading branch information
shilman committed Jan 14, 2019
2 parents 8ab583b + 3822e58 commit 0b296e1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions lib/core/src/server/cli/dev.js
Expand Up @@ -34,6 +34,7 @@ async function getCLI(packageJson) {
.option('--smoke-test', 'Exit after successful start')
.option('--ci', "CI mode (skip interactive prompts, don't open browser")
.option('--quiet', 'Suppress verbose build output')
.option('--no-dll', 'Do not use dll reference')
.parse(process.argv);

logger.info(chalk.bold(`${packageJson.name} v${packageJson.version}`) + chalk.reset('\n'));
Expand Down
1 change: 1 addition & 0 deletions lib/core/src/server/cli/prod.js
Expand Up @@ -13,6 +13,7 @@ function getCLI(packageJson) {
.option('-c, --config-dir [dir-name]', 'Directory where to load Storybook configurations from')
.option('-w, --watch', 'Enable watch mode')
.option('--quiet', 'Suppress verbose build output')
.option('--no-dll', 'Do not use dll reference')
.parse(process.argv);

logger.info(chalk.bold(`${packageJson.name} v${packageJson.version}\n`));
Expand Down
1 change: 1 addition & 0 deletions lib/core/src/server/dev-server.js
Expand Up @@ -37,6 +37,7 @@ export default async function(options) {
configDir,
cache,
corePresets: [require.resolve('./manager/manager-preset.js')],
...options,
}).then(
config =>
new Promise((resolve, reject) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/core/src/server/manager/manager-preset.js
Expand Up @@ -7,7 +7,7 @@ export async function managerWebpack(_, options) {

export async function managerEntries(_, options) {
const { presets } = options;
const entries = [];
const entries = [require.resolve('../common/polyfills')];

const installedAddons = await presets.apply('addons', [], options);

Expand Down
20 changes: 11 additions & 9 deletions lib/core/src/server/manager/manager-webpack.config.js
Expand Up @@ -12,11 +12,11 @@ import { getManagerHeadHtml } from '../utils/template';
import { loadEnv } from '../config/utils';
import babelLoader from '../common/babel-loader';

// const coreDirName = path.dirname(require.resolve('@storybook/core/package.json'));
// const context = path.join(coreDirName, '../../node_modules');
const coreDirName = path.dirname(require.resolve('@storybook/core/package.json'));
const context = path.join(coreDirName, '../../node_modules');
const cacheDir = findCacheDir({ name: 'storybook' });

export default ({ configDir, configType, entries, outputDir, cache, babelOptions }) => {
export default ({ configDir, configType, entries, dll, outputDir, cache, babelOptions }) => {
const { raw, stringified } = loadEnv();
const isProd = configType === 'PRODUCTION';

Expand All @@ -33,10 +33,12 @@ export default ({ configDir, configType, entries, outputDir, cache, babelOptions
},
cache,
plugins: [
// new webpack.DllReferencePlugin({
// context,
// manifest: path.join(__dirname, '../../../dll/storybook_ui-manifest.json'),
// }),
dll
? new webpack.DllReferencePlugin({
context,
manifest: path.join(__dirname, '../../../dll/storybook_ui-manifest.json'),
})
: null,
new HtmlWebpackPlugin({
filename: `index.html`,
chunksSortMode: 'none',
Expand All @@ -47,15 +49,15 @@ export default ({ configDir, configType, entries, outputDir, cache, babelOptions
files,
options,
version,
dlls: ['/sb_dll/storybook_ui_dll.js'],
dlls: dll ? ['./sb_dll/storybook_ui_dll.js'] : [],
headHtmlSnippet: getManagerHeadHtml(configDir, process.env),
}),
template: require.resolve(`../templates/index.ejs`),
}),
new webpack.DefinePlugin({ 'process.env': stringified }),
new CaseSensitivePathsPlugin(),
new Dotenv({ silent: true }),
],
].filter(Boolean),
module: {
rules: [babelLoader(babelOptions)],
},
Expand Down

0 comments on commit 0b296e1

Please sign in to comment.