Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI and GULP not working correctly. #239

Closed
Kcko opened this issue Nov 15, 2019 · 1 comment
Closed

CLI and GULP not working correctly. #239

Kcko opened this issue Nov 15, 2019 · 1 comment

Comments

@Kcko
Copy link

Kcko commented Nov 15, 2019

Im trying purgecss via two ways.

  1. Via CLI with this command npx purgecss --css build.css --out build2 --content ["*.html"]
  2. Via gulp
const purgecss = require('gulp-purgecss')

gulp.task('purgecss', () => {
  return gulp
    .src('build.css')
    .pipe(
      purgecss({
        content: ['index.html']
      })
    )
    .pipe(gulp.dest('build/'))
})

My HTML file (index.html):

    <header class="container border-4 p-4 bg-blue-300">
        <h1 class="text-4xl p-2 m-3 bg-orange-300 relative">Test</h1>
    </header>
    <section class="flex w-full text-2xl">
        <div class="col bg-red-200 w-1/2 p-4 text-6xl">A</div>
        <div class="col bg-green-300 w-1/5 p-4">B</div>
        <div class="col bg-green-300 w-1/6 p-4">C</div>
    </section>

and result after build?

  1. CLI always ending with
canvas {
  display: block;
  vertical-align: middle;
}

/**
 * Constrain images and videos to the parent width and preserve
 * their instrinsic aspect ratio.
 *
 * https://github.com/mozdevs/cssremedy/issues/14
 */

Absolutely no used css classess are preserved.

  1. Gulp works better, but some css classes still not preserved

.container {
  width: 100%;
}

@media (min-width: 640px) {
  .container {
    max-width: 640px;
  }
}

@media (min-width: 768px) {
  .container {
    max-width: 768px;
  }
}

@media (min-width: 1024px) {
  .container {
    max-width: 1024px;
  }
}

@media (min-width: 1280px) {
  .container {
    max-width: 1280px;
  }
}

.bg-red-200 {
  background-color: #fed7d7;
}

.bg-orange-300 {
  background-color: #fbd38d;
}

.bg-green-300 {
  background-color: #9ae6b4;
}

.bg-blue-300 {
  background-color: #90cdf4;
}

.border-4 {
  border-width: 4px;
}

.flex {
  display: -webkit-box;
  display: flex;
}

.m-3 {
  margin: 0.75rem;
}

.p-2 {
  padding: 0.5rem;
}

.p-4 {
  padding: 1rem;
}

.relative {
  position: relative;
}

.text-2xl {
  font-size: 1.5rem;
}

.text-4xl {
  font-size: 2.25rem;
}

.text-6xl {
  font-size: 4rem;
}

.w-1 {
  width: 0.25rem;
}

.w-full {
  width: 100%;
}

w-1 - im not using!, why it is on the list?!
w-1/5 or w-1/2 is missing

Really strange behavior, some explanation pls? I dont really understand ...

@Kcko
Copy link
Author

Kcko commented Nov 15, 2019

Solved! My mistakes (and my beginner level with purge css).

  1. bad params ... ['index.html'] must be only index.html
    1+2 are solved by extractors thx https://github.com/FullHuman/purgecss/tree/master/examples/cli/config-file

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

No branches or pull requests

1 participant