mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
454a9af242
Co-authored-by: Daniel Roe <daniel@roe.dev>
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
import path from 'path'
|
|
import PurgecssPlugin from 'purgecss-webpack-plugin'
|
|
import glob from 'glob-all'
|
|
|
|
class TailwindExtractor {
|
|
static extract (content) {
|
|
return content.match(/[A-Za-z0-9-:/]+/g) || []
|
|
}
|
|
}
|
|
|
|
export default {
|
|
build: {
|
|
extractCSS: true,
|
|
postcss: {
|
|
postcssOptions: {
|
|
plugins: {
|
|
tailwindcss: path.resolve('./tailwind.js')
|
|
}
|
|
},
|
|
preset: { autoprefixer: { grid: true } }
|
|
},
|
|
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,
|
|
extensions: ['vue']
|
|
}
|
|
],
|
|
whitelist: ['html', 'body', 'nuxt-progress']
|
|
})
|
|
)
|
|
}
|
|
}
|
|
},
|
|
css: ['~/assets/css/tailwind.css']
|
|
}
|