-
Notifications
You must be signed in to change notification settings - Fork 0
/
preact.config.js
35 lines (29 loc) · 1.18 KB
/
preact.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const notFoundError = name => `Please pass the ${name} parameter to plugin`;
const defaultParams = {
regex: /[\w-/:]+(?<!:)/g,
};
// derived from https://github.com/agneym/preact-cli-tailwind
// I got an issue with font so I modify the source and also I added whitelist
module.exports = (config, env, helpers, params = defaultParams) => {
if (!config) throw new Error(notFoundError("config"));
if (!env) throw new Error(notFoundError("env"));
if (!helpers) throw new Error(notFoundError("helpers"));
const purgecss = require('@fullhuman/postcss-purgecss')({
// Specify the paths to all of the template files in your project
content: ['./build/**/*.js', './build/**/*.html'],
css: ['./build/**/*.css'],
whitelist: ['body'],
defaultExtractor: content => content.match(/[\w-/:]+(?<!:)/g) || []
})
const postCssLoaders = helpers.getLoadersByName(config, "postcss-loader");
postCssLoaders.forEach(({ loader }) => {
const plugins = loader.options.plugins;
// Add tailwind css at the top.
plugins.unshift(require("tailwindcss"));
// Add PurgeCSS only in production.
if (env.production) {
plugins.push(purgecss);
}
});
return config;
};