purifycss-webpack
purifycss-webpack copied to clipboard
Without the ExtractTextPugin?
Hello! Its's all in the question, I'd like to use the purifycss for generating the css and placing it in the html file not on a separate .css file! Did not find an example of doing that with purifycss-webpack. Is it possible at all? Thx in advance
I haven't tried that. How do you generate the html files?
Hello bebraw,
In the "entry point" app.js or main.js i do require/import the css file
const css = require('../css/app.css');
Obviously in webpack.config, inside module.rules I do add the rule:
{ test: /\.css$/, use:["style-loader","css-loader"] }
In the same webpack.config file I add under resolve
extensions: ['css', '.jsx', '.js'],
The above configuration would insert the app.css file contents in the output file (index.html) within a
What I'd like to use purifycss for is to only include used css rules and not all of app.css
Ohh, i forgot the line added just to use purifycss
,new PurifyCSSPLugin({paths: [glob.sync(path.join(__dirname, "/src/index.html"))]})
I wanted to see if I do not use all css rules within the index.html if that would result in less css inside my style tag (as discussed above) but it's failing to do anything. All of app.css is included even fake/dummy rules not used in index.html or anyone else.
The problem is that the plugin has been designed to operate against files emitted by webpack.
I can accept a PR that implements a loader to achieve what you want.
Ok, thx bebraw. I am afraid i'm not a good candidate for such task as i can barely use webpack. I guess I will have to manually clean the css :)
@mehdi-cit It's alright. Let's leave this issue open in case someone wants to tackle it.
I'm having the same problem. I think this plugin should be used as a loader to execute after "css-loader" or "style-loader".