Skip to content

Commit

Permalink
feat: add nuxt build indicator to whitelist in dev mode (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
homerjam committed Apr 29, 2020
1 parent 9345ebf commit c123fef
Showing 1 changed file with 37 additions and 29 deletions.
66 changes: 37 additions & 29 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,41 @@ const MODES = {

module.exports = {
MODES,
getDefaults: options => ({
mode: MODES.postcss,
enabled: options.dev === false,
paths: [
'components/**/*.vue',
'layouts/**/*.vue',
'pages/**/*.vue',
'plugins/**/*.js',
'nuxt.config.js'
],
styleExtensions: ['.css'],
whitelist: ['body', 'html', 'nuxt-progress', '__nuxt', '__layout'],
whitelistPatterns: [
/-(leave|enter|appear)(|-(to|from|active))$/, // Normal transitions
/^nuxt-link(|-exact)-active$/, // Nuxt link classes
/^(?!cursor-move).+-move$/, // Move transitions
/data-v-.*/ // Keep scoped styles
],
whitelistPatternsChildren: [],
extractors: [
{
extractor: (content) => {
const contentWithoutStyleBlocks = content.replace(/<style[^]+?<\/style>/gi, '') // Remove inline vue styles
return contentWithoutStyleBlocks.match(/[\w-.:/]+(?<!:)/g) || []
},
extensions: ['html', 'vue', 'js']
}
]
})
getDefaults (options) {
const defaults = {
mode: MODES.postcss,
enabled: options.dev === false,
paths: [
'components/**/*.vue',
'layouts/**/*.vue',
'pages/**/*.vue',
'plugins/**/*.js',
'nuxt.config.js'
],
styleExtensions: ['.css'],
whitelist: ['body', 'html', 'nuxt-progress', '__nuxt', '__layout'],
whitelistPatterns: [
/-(leave|enter|appear)(|-(to|from|active))$/, // Normal transitions
/^nuxt-link(|-exact)-active$/, // Nuxt link classes
/^(?!cursor-move).+-move$/, // Move transitions
/data-v-.*/ // Keep scoped styles
],
whitelistPatternsChildren: [],
extractors: [
{
extractor: (content) => {
const contentWithoutStyleBlocks = content.replace(/<style[^]+?<\/style>/gi, '') // Remove inline vue styles
return contentWithoutStyleBlocks.match(/[\w-.:/]+(?<!:)/g) || []
},
extensions: ['html', 'vue', 'js']
}
]
}

if (options.dev) {
defaults.whitelist.push('nuxt__build_indicator')
}

return defaults
}
}

0 comments on commit c123fef

Please sign in to comment.