update webpack config to work with current dependencies

change purgecss extractor to tailwind recommendation

fix CopyWebpackPlugin configuration syntax
This commit is contained in:
MarcoGlauser 2020-09-25 16:03:04 +01:00
parent c8a4073811
commit 8dcfab79cb

View file

@ -35,16 +35,15 @@ if ( isProduction ) {
css: [ css: [
'./node_modules/tailwindcss/dist/base.css' './node_modules/tailwindcss/dist/base.css'
], ],
extractors: [ defaultExtractor: content => {
{ // Capture as liberally as possible, including things like `h-(screen-1.5)`
extractor: class TailwindExtractor { const broadMatches = content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || []
static extract(content) {
return content.match(/[A-Za-z0-9-_:\/]+/g) || []; // Capture classes within other delimiters like .block(class="w-1/2") in Pug
} const innerMatches = content.match(/[^<>"'`\s.()]*[^<>"'`\s.():]/g) || []
},
extensions: ['php', 'js', 'svg', 'css',] return broadMatches.concat(innerMatches)
} },
],
whitelistPatterns: getCSSWhitelistPatterns() whitelistPatterns: getCSSWhitelistPatterns()
}) })
) )
@ -87,7 +86,6 @@ const config = {
loader: 'css-loader', loader: 'css-loader',
options: { options: {
importLoaders: 1, importLoaders: 1,
context: 'postcss',
sourceMap: ! isProduction sourceMap: ! isProduction
} }
}, },
@ -113,13 +111,12 @@ const config = {
new MiniCssExtractPlugin({ new MiniCssExtractPlugin({
filename: `[name]${prefix}.css`, filename: `[name]${prefix}.css`,
}), }),
new CopyWebpackPlugin([{ new CopyWebpackPlugin({
from: './assets/images/', patterns: [{
to: 'images', from: './assets/images/',
ignore: [ to: 'images',
'.DS_Store' }]
] }),
}]),
new ImageminPlugin({ test: /\.(jpe?g|png|gif|svg)$/i }) new ImageminPlugin({ test: /\.(jpe?g|png|gif|svg)$/i })
] ]
} }
@ -180,4 +177,4 @@ function getCSSWhitelistPatterns() {
]; ];
} }
module.exports = config module.exports = config