Nuxt/examples/with-purgecss/nuxt.config.js

43 lines
1.1 KiB
JavaScript
Raw Normal View History

const path = require('path')
const PurgecssPlugin = require('purgecss-webpack-plugin')
const glob = require('glob-all')
class TailwindExtractor {
static extract(content) {
2018-03-11 11:04:44 +00:00
return content.match(/[A-z0-9-:/]+/g) || []
}
}
module.exports = {
build: {
extractCSS: true,
postcss: [
require('tailwindcss')('./tailwind.js'),
require('autoprefixer')
],
2018-03-11 11:04:44 +00:00
extend(config, { isDev }) {
if (!isDev) {
config.plugins.push(
new PurgecssPlugin({
// purgecss configuration
// https://github.com/FullHuman/purgecss
paths: glob.sync([
path.join(__dirname, './pages/**/*.vue'),
path.join(__dirname, './layouts/**/*.vue'),
path.join(__dirname, './components/**/*.vue')
]),
extractors: [
{
extractor: TailwindExtractor,
2018-03-11 11:04:44 +00:00
extensions: ['vue']
}
],
whitelist: ['html', 'body', 'nuxt-progress']
})
)
}
}
},
css: ['~/assets/css/tailwind.css']
}