webpack-contrib / purifycss-webpack

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

Support for React (typescript) with inline CSS, is this possible? #133

Open sandrocsimas opened 6 years ago

sandrocsimas commented 6 years ago

I have a React project (typescript) that bundles to a single JS file including everything. PurifyCSS webpack plugin is not working as expected. The following is the relevant code of my Webpack config:

{
  test: /\.less$/,
  use: [
    'style-loader',
    {
      loader: 'css-loader',
      options: {
        minimize: env === 'production',
      },
    },
    'less-loader',
  ],
  include: helpers.root('/src/assets/styles'),
}
new PurifyCSSPlugin({
  paths: glob.sync(`${helpers.root('/src')}/**/*`),
  styleExtensions: ['.js', '.css', '.less'],
  moduleExtensions: ['.js'],
  verbose: true,
})

This project doesn't have HTML files, only Typescript and Less files. How to use PurifyCSS in this case? This only works using ExtractTextPlugin?

sandrocsimas commented 6 years ago

It seems the plugin only read the output files. Is there a way to use it as a loader? The purifycss should be applied after "css-loader" of "style-loader".