Skip to content

Instantly share code, notes, and snippets.

@andrejsharapov
Created March 8, 2021 21:49
Show Gist options
  • Save andrejsharapov/d620d52001a91feecb65c1a9009f640a to your computer and use it in GitHub Desktop.
Save andrejsharapov/d620d52001a91feecb65c1a9009f640a to your computer and use it in GitHub Desktop.
PurgeCSS for a Nuxt
export default {
buildModules: [
'nuxt-purgecss',
],
purgeCSS: {
paths: [
'components/**/*.vue',
'layouts/**/*.vue',
'pages/**/*.vue',
'plugins/**/*.js',
'node_modules/@nuxtjs/vuetify/**/*.ts',
'node_modules/@nuxt/vue-app/template/**/*.html',
'node_modules/@nuxt/vue-app/template/**/*.vue',
],
extractors: [
{
extractor: (content) => content.match(/[A-z0-9-:\\/]+/g) || [],
extensions: ['html', 'vue', 'js'],
},
],
styleExtensions: ['.css'],
whitelist: ['v-application', 'v-application--wrap'],
whitelistPatterns: [
/^v-((?!application).)*$/,
/^\.theme--dark*/,
/.*-transition/,
],
whitelistPatternsChildren: [
/^v-((?!application).)*$/,
/^theme--dark.*/,
/.*-transition/,
],
},
build: {
extractCSS: true,
postcss: {
plugins: {
'postcss-custom-media': {},
'postcss-hexrgba': {},
'postcss-mixins': {},
'postcss-nested': {},
'postcss-responsive-type': {},
'postcss-sorting': {},
'postcss-url': {},
'postcss-utilities': {},
precss: {},
'@fullhuman/postcss-purgecss': {
content: [
'components/**/*.vue',
'layouts/**/*.vue',
'pages/**/*.vue',
'plugins/**/*.js',
'node_modules/vuetify/src/**/*.ts',
],
styleExtensions: ['.css'],
safelist: {
standard: ['body', 'html', 'nuxt-progress'],
deep: [
/page-enter/,
/page-leave/,
/dialog-transition/,
/tab-transition/,
/tab-reversetransition/,
],
},
},
'css-byebye': {
rulesToRemove: [/.*\.v-application--is-rtl.*/, /.*\.theme--dark.*/],
},
},
preset: {
features: {
'nesting-rules': true,
'custom-media-queries': true,
},
},
}
}
}
"devDependencies": {
"@fullhuman/postcss-purgecss": "^4.0.2",
"nuxt-purgecss": "^1.0.0",
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment