webpack-contrib / purifycss-webpack

UNMAINTAINED, use https://github.com/FullHuman/purgecss-webpack-plugin
MIT License
772 stars 37 forks source link

Example for migrating from purifycss/purifycss-webpack-plugin #75

Closed t47io closed 7 years ago

t47io commented 7 years ago

Hi, I had no luck migrating from the old purifycss/purifycss-webpack-plugin to this new webpack-contrib/purifycss-webpack. Can anyone spot what's wrong?

My old config for purifycss/purifycss-webpack-plugin:

    new PurifyCSSPlugin({
      basePath: rootPath,
      paths: [
       'app/**/*.jsx',
       'app/**/*.json',
       'public/**/*.html'
      ],
      purifyOptions: {
        minify: true,
        info:true,
        rejected: true
      }
    }),

New config for webpack-contrib/purifycss-webpack:

    new PurifyCSSPlugin({
      paths: [
        ...(glob.sync(`${rootPath}/app/**/*.jsx`)),
        ...(glob.sync(`${rootPath}/app/**/*.json`)),
        ...(glob.sync(`${rootPath}/public/**/*.html`))
      ],
      purifyOptions: {
        minify: true,
        info: true,
        rejected: true
      }
    }),

No effect for any changes. Not sure if I got the paths correct. Should it combine the old basePath and paths, but using glob?

P.S> {purifyOptions: { info: true} } as above does not work. Have to use verbose: true.

P.P.S> For my config, all the verbose I got is an empty line like this:

Assets to purify:
t47io commented 7 years ago

using:

webpack                       2.2.1
purifycss-webpack             0.4.2
extract-text-webpack-plugin   2.0.0-rc.3

used to be purifycss-webpack-plugin 2.0.3

P.P.P.S> I have this before the new PurifyCSSPlugin({...})

    new ExtractTextPlugin({
      filename: "[name]-[hash:8].css",
      allChunks: true
    }),

and in module.rules:

    {
      test: /\.scss$/i,
      use: ExtractTextPlugin.extract({
        fallback: "style-loader",
        use: [
          "css-loader",
          "sass-loader"
        ]
      })
    },
bebraw commented 7 years ago

I would need a little project to study to say anything concrete. Maybe someone else has a better idea.

martin-svk commented 7 years ago

Hi, I have similar problem. Looks like it is very hard to figure out how to set the path / paths attribute. Tried several modifications, but no luck.

I am doing this:

paths: glob.sync(path.join(__dirname, '../dist/*.html')),

and my old, working config was:

new Purify({
        basePath: __dirname,
        paths: [
            'dist/*.html
        ]
})
bebraw commented 7 years ago

Little standalone projects would help to debug these.

gw0 commented 7 years ago

I think that the problem could be that glob.sync() is evaluated before Webpack generates those files (that could contain a hash or other non-static name).