While webpack seems to support a wide variety of detailed configuration options, I only want to accomplish the simple task of taking a single css source file located at project/frontend/static/css/style.css and outputting a minified version of that css file to project/frontend/static/css/style.min.css. I can't seem to find anything in the documentation of webpack that discusses this, as I am not importing my CSS from JS, just linking it in the HTML head the old fashioned way, so all I want to output is a plain CSS file, just minified.
-
I don't think it's possible to do without having a JS entry file to give to webpack. You could use this command line tool maybe? npmjs.com/package/css-minifyGaurav Punjabi– Gaurav Punjabi2020-01-29 05:24:10 +00:00Commented Jan 29, 2020 at 5:24
Add a comment
|
1 Answer
With webpack you may like to use mini-css-extract-plugin
npm install --save-dev mini-css-extract-plugin
This plugin extracts CSS into separate files. It creates a CSS file per JS file which contains CSS. It supports On-Demand-Loading of CSS and SourceMaps.
It builds on top of a new webpack v4 feature (module types) and requires webpack 4 to work.
Please look at the documentation for more info https://webpack.js.org/plugins/mini-css-extract-plugin/
1 Comment
lordvcs
Does this work without importing CSS into a JS file(which what he asked)?.