purifycss-webpack icon indicating copy to clipboard operation
purifycss-webpack copied to clipboard

Without the ExtractTextPugin?

Open mehdi-cit opened this issue 7 years ago • 6 comments

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

mehdi-cit avatar May 01 '17 16:05 mehdi-cit

I haven't tried that. How do you generate the html files?

bebraw avatar May 01 '17 16:05 bebraw

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.

mehdi-cit avatar May 01 '17 18:05 mehdi-cit

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.

bebraw avatar May 01 '17 19:05 bebraw

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 avatar May 01 '17 20:05 mehdi-cit

@mehdi-cit It's alright. Let's leave this issue open in case someone wants to tackle it.

bebraw avatar May 02 '17 07:05 bebraw

I'm having the same problem. I think this plugin should be used as a loader to execute after "css-loader" or "style-loader".

sandrocsimas avatar May 09 '18 14:05 sandrocsimas