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