Skip to content

Instantly share code, notes, and snippets.

@vkaelin
Created January 11, 2019 14:24
Show Gist options
  • Save vkaelin/d0781e0e74bf87a11d404f369c522a0a to your computer and use it in GitHub Desktop.
Save vkaelin/d0781e0e74bf87a11d404f369c522a0a to your computer and use it in GitHub Desktop.
Config Webpack Tailwind PurgeCSS
const path = require('path')
const glob = require('glob')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const PurgecssPlugin = require('purgecss-webpack-plugin')
const PATHS = {
src: path.join(__dirname, 'src')
}
module.exports = {
entry: './src/styles.css',
mode: process.env.NODE_ENV,
module: {
rules: [
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{ loader: 'css-loader', options: { importLoaders: 1 } },
'postcss-loader',
],
}),
},
],
},
plugins: [
new ExtractTextPlugin('styles.css', {
disable: process.env.NODE_ENV === 'development',
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'src/index.html',
}),
new PurgecssPlugin({
paths: glob.sync(`${PATHS.src}/*`)
})
],
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment