Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Purge-Problem #7

Closed
coolskin2b opened this issue Feb 15, 2021 · 2 comments
Closed

Purge-Problem #7

coolskin2b opened this issue Feb 15, 2021 · 2 comments

Comments

@coolskin2b
Copy link

coolskin2b commented Feb 15, 2021

Hello,
First thanks for what you have done Stefan.
I m looking about the result of the build optimization for the css and i always got 3mo of css file.
I m new with thailwind and webpack.
I found this doc about purgecss and webpack :
https://purgecss.com/plugins/webpack.html#usage
after added :

yarn add purgecss-webpack-plugin --dev

i added this lines in webpack.prod.js

const PurgecssPlugin = require('purgecss-webpack-plugin')
  ...

  new Dotenv({
    path: './.env.production',
  }),
  // Extracts CSS into separate files
  // Note: style-loader is for development, MiniCssExtractPlugin is for production
  new MiniCssExtractPlugin({
    filename: 'styles/[name].[contenthash].css',
    chunkFilename: '[id].css',
  }),
// added this lines :
    new PurgecssPlugin({
    paths: glob.sync(`${paths.src}/**/*`, { nodir: true }),
  }),
// end of lines
],

When i have done that the css file size now is : 3 ko.

Do you think this is the good way to reduce the css size or i m wrong and i miss something with your project?

Thanks in advance.

@coolskin2b coolskin2b changed the title Purge Problem, maybe Purge-Problem Feb 15, 2021
@avrapaulo
Copy link

avrapaulo commented Feb 18, 2021

Hey, you don't need to install any additional packages because tailwindcss already gives you this functionality. Everything is set up for that just a little detail is missing. Change this 25 line in package.json

"build": "NODE_ENV=production webpack --config config/webpack.prod.js",

Now it removes unused CSS you will have around 5kb files.

stefanwuthrich pushed a commit that referenced this issue Feb 19, 2021
@stefanwuthrich
Copy link
Contributor

First of all, tk you @coolskin2b to point this out.
And tk you @avrapaulo for the solution which is obviously correct. I somewhere removed that and....
It's fixed now. Tks to both.:-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants