storybook: Storybook 3.2 is failing to build static export
- using @storybook/react 3.2.0
.babelrc
{ "presets": ["es2015", "stage-0", "react"] }
Running build-storybook throws this error. It looks like we should use uglifyjs-webpack-plugin according to https://stackoverflow.com/questions/42375468/uglify-syntaxerror-unexpected-token-punc
Building storybook … Failed to build the storybook static/manager.7b465898ead542baaf4e.bundle.js from UglifyJs Unexpected token: punc ()) [static/manager.7b465898ead542baaf4e.bundle.js:45694,3] static/preview.577ee8de40d8c6c75e21.bundle.js from UglifyJs Unexpected token: punc ()) [static/preview.577ee8de40d8c6c75e21.bundle.js:131238,3]
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 7
- Comments: 26 (13 by maintainers)
Commits related to this issue
- add workaround for building a static version see https://github.com/storybooks/storybook/issues/1570 for details — committed to evgenykochetkov/react-storybook-addon-props-combinations by evgenykochetkov 7 years ago
- add workaround for building a static version see https://github.com/storybooks/storybook/issues/1570 for details — committed to evgenykochetkov/react-storybook-addon-props-combinations by evgenykochetkov 7 years ago
- not support https://github.com/storybooks/storybook/issues/1570 — committed to roderickhsiao/react-in-viewport by roderickhsiao 7 years ago
- https://github.com/storybooks/storybook/issues/1570 — committed to roderickhsiao/react-aspect-ratio by roderickhsiao 7 years ago
- [RSP-20] React 16 Upgrade (#85) * RSP-20:React 16 upgrade * RSP-20:React 16 upgrade *updating tests(failed) * RSP-20:React 16 upgrade *updating tests(failed) * did some updates to libraries * upd... — committed to fezproof/projects by devongovett 7 years ago
storybookBaseConfig.plugins.pop();It relies on the fact that uglify plugin is first, I use
plugins = plugins.filter(plugin => plugin.constructor.name !== 'UglifyJsPlugin'instead (when addressing an issue with third-party addon)Will try and come up with a pull request over the next couple of days…
build-storybook doesn’t currently use the custom
.babelrc. If anyone wants to try and fix it, please do.issue tracked here: https://github.com/storybooks/storybook/issues/1731
@danielduan I’ve recently upgraded a bunch of webpack configs to use the uglifyjs-webpack-plugin which uses uglifyjs v1, rather than 0.4* that is under webpack.optimize.UglifyJsPlugin. I did the same in the extension mode of the storybook webpack config by removing the existing plugin and adding uglifyjs-webpack-plugin instead. The issue appears fixed, so maybe upgrading the webpack config to use this plugin by default rather than the bundled webpack plugin might help?
(I haven’t had any issues upgrading to the latest uglifyjs, however I didn’t do a full analysis of the changes between the 2 versions, and the webpack team hasn’t upgraded to this. This could be because the config format for the v1 version has changed)
@ndelangen why does storybook’s static build even require minification, would it not be beneficial to leave it unminified because the end users might want to check the output in react developer tools to see the components if this tool is meant for development?
Also, if I use another minifier plugin in my
.storybook/webpack.config.js, would that remove UglifyJs as the minifer. Is there a way to opt out of minification when usingbuild-storybook.Also, given that you do not support a custom babel config, why should I use a babel config for the entire app that transpiles to ES5 when most browsers have good support for ES6.
If anyone else needs a quick workaround for this issue that still minifies the static build here’s my workaround. It swaps the Webpack plugin for UglifyJs with the plugin for babel minify.
babel-minify-webpack-pluginwebpack.config.jsinside.storybook/FYI, our
webpack.config.js:I have the same issue:
This could be because UglifyJS doesn’t support any ES6 yet. Make sure babel is transpiling down to ES5.