You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CSS is not minified in prod build with master #1934
When I'm building to production with the master version of create-react-app, the css is not minified. With the latest released version (v0.9.5) however, it is being minified.
Expected behavior
The css file under build/static/css/ should be minified.
Actual behavior
It is not minified.
Environment
Run these commands in the project folder and fill in their results:
npm ls react-scripts (if you haven’t ejected): Running from master, see below.
node -v: v7.7.3
npm -v: 4.4.4
Then, specify:
Operating system: Arch Linux
Browser and version: Irrelevant
Reproducible Demo
I can reproduce this by running these commands:
git clone git@github.com:facebookincubator/create-react-app.git .
npm i
npm run create-react-app test-css-minify
cd test-css-minify
npm run build
And looking at the css file that is built under build/static/css/.
looks as though minimize is set to true for the HtmlWebpackPlugin which uses the html-minifier internally but from the docs it seems as this only handles minification of css in style elements and style attributes. See the screenshots attached. In-order to minify the external css the css-loader option would need to be set to true as follows:
Activity
viankakrisna commentedon Apr 6, 2017
seems like minimize option is not turned on in https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/config/webpack.config.prod.js#L198-L200.
shaunwallace commentedon Apr 20, 2017
looks as though minimize is set to true for the HtmlWebpackPlugin which uses the html-minifier internally but from the docs it seems as this only handles minification of css in style elements and style attributes. See the screenshots attached. In-order to minify the external css the css-loader option would need to be set to true as follows:
{ loader: 'css-loader', options: { importLoaders: 1, minimize: true, }, }but the above uses cssnano and I am not sure that by setting this boolean to true, which options would be wanted.
[Fixes react#1934] turn on minimize for css-loader