-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostcss.config.js
37 lines (35 loc) · 1.1 KB
/
postcss.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
36
37
const { version } = require('./package.json');
const { defaultPlugins } = require('./lib/postcss-plugins');
const path = require('path');
const extractMediaQuery = require('./lib/plugins/postcss-extract-media-query');
const header = require('./lib/plugins/postcss-header');
const minify = require('@csstools/postcss-minify');
const extractDarkModeQueries = (dest, prod = false) =>
extractMediaQuery({
prepend: `/*! lookbook-dark-mode.css v${version} */`,
output: {
path: dest,
name: `[name]-[query]${prod ? '.min' : ''}.css`,
},
whitelist: true,
minimize: prod,
stats: false,
queries: {
'screen and (prefers-color-scheme: dark)': 'dark-mode',
},
});
// Internal config, used to build *this* .css.
module.exports = (ctx) => ({
map: ctx.options.map, // Sourcemaps
plugins: [
...defaultPlugins(),
extractDarkModeQueries(
path.join(__dirname, 'dist'),
ctx.env === 'production'
),
header({
header: `/*! ${ctx.file.basename} v${version} ${new Date().toISOString()} */`,
}),
...(ctx.env === 'production' ? [minify] : []),
],
});