npm list --depth=0)node -v): 7.9.0npm -v): 4.5.0Unable to remove comments in CSS and/or JS during compiling. The only way is to manually edit webpack.config.js to add the parameters:
{ comments: false }
However, webpack.config.js is inside the node_modules directory, so the changes will not be pushed to git.
Just run any npm run <script> and comments are not removed.
@JeffreyWay Any clue to this?
Comments will automatically be stripped when you compile for production. npm run production.
It appears that Font Awesome comments, in the form of this chunk is not being removed.
*!
* Font Awesome 4.7.0 by @davegandy - http://fontawesome.io - @fontawesome
* License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License)
*/
However, the one in SimpleMDE is being removed.
/**
* simplemde v1.11.2
* Copyright Next Step Webs, Inc.
* @link https://github.com/NextStepWebs/simplemde-markdown-editor
* @license MIT
*/
This behaviour is being weird.
@ruchern To anyone that needs a solution to this.
You can provide custom options to the webpack modules in webpack.mix.js, the original options are displayed in /node_modules/laravel-mix/src/Options.js
In laravel 5.4 i provided additional config option like below and all comments were stripped from my minified code, js and css alike.
mix.options({
postCss: [
require('postcss-discard-comments')({
removeAll: true
})
],
uglify: {
comments: false
}
})
You do need the postcss-discard-comments module for this.
I think in the current version of laravel-mix it is done like this (not tested):
mix.options({
postCss: [
require('postcss-discard-comments')({
removeAll: true
})
],
uglify: {
uglifyOptions: {
comments: false
},
}
})
If you want to remove all comments add this to your mix options (laravel-mix: 4)
mix.options({
cssNano: {
discardComments: {
removeAll: true,
},
},
})
P.S. @ruchern this comments not removed because starts with *!, see docs
Most helpful comment
If you want to remove all comments add this to your mix options (laravel-mix: 4)
P.S. @ruchern this comments not removed because starts with
*!, see docs