-
-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSS files not minimized in production build? #432
Comments
Preview of our config: Encore
.setOutputPath(outputPath)
.setPublicPath(publicPath)
// Clean output dir before build
.cleanupOutputBeforeBuild()
.splitEntryChunks()
.enableSingleRuntimeChunk()
// Generate JS files
.addEntry('main', './assets/javascript/main.js')
.enableEslintLoader()
.configureTerserPlugin((options) => {
options.cache = true;
options.parallel = true;
options.terserOptions = {
output: {
comments: false,
},
};
})
// Generate CSS files
.addStyleEntry('base', './assets/styles/base.scss')
.addStyleEntry('components', './assets/styles/components.scss')
.addStyleEntry('layout', './assets/styles/layout.scss')
// Enable SASS loader with PostCSS config
.enableSassLoader((options) => {
options.sourceComments = !Encore.isProduction();
options.outputStyle = 'compressed';
}, {})
.enablePostCssLoader()
.enableSourceMaps(!Encore.isProduction())
.enableVersioning(Encore.isProduction())
// CSS Hot Loader for HMR in webpack dev server
.addLoader({
enforce: 'post',
test: /\.(s?c|sa)ss$/,
exclude: /node_modules/,
loader: 'css-hot-loader',
})
.addPlugin(new StyleLintPlugin({
lintDirtyModulesOnly: Encore.isProduction(),
context: './assets/styles/',
quiet: false,
})); Does anyone face the same problem? @weaverryan @Lyrkan |
Currently, I added a custom CSS compression plugin. const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
if (Encore.isProduction()) {
Encore
// @see: https://github.com/NMFR/optimize-css-assets-webpack-plugin
.addPlugin(new OptimizeCssAssetsPlugin({
assetNameRegExp: /\.(c|s[ac])ss$/,
cssProcessorPluginOptions: {
preset: ['default', {
discardComments: {
removeAll: false // remove any comments?
}
}],
},
canPrint: true,
}));
} |
Thanks @jfcherng, we've done that already but I would like to not use external library when encore should do it alone in the background. :) We will see if we get any reaction on this issue. |
Yea, this should not require an outside plugin. I just triple-checked, on SymfonyCasts.com (for example) the CSS is minified just fine. There may be something custom in your setup, though nothing looks very "weird"... except for maybe |
@weaverryan well I tried to disable plugins one by one but with no luck. The |
@weaverryan well ye, looks like we have ‘ "css-loader": "^1.0.1"’ there. So probably thats the problem? :-) |
@weaverryan looks like it was the problem. I just removed |
Excellent! That means the linked PR will fix the problem no matter what. Thanks for confirming! |
Trying to figure out why our CSS files are not minimized when use
encore production
. JS files are minimized without any problems but CSS files not, any ideas why?The text was updated successfully, but these errors were encountered: