-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It's problematic, since it doesn't recognise at-rules such as @container and @starting-style. It's also quite unmaintained.
- Loading branch information
Showing
7 changed files
with
68 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,18 @@ | ||
// A React/Preact centric PostCSS config for Lookbook | ||
|
||
// Default PostCSS plugins in able for the Lookbook to work | ||
const { defaultPostCssPlugins } = require('@lookback/lookbook'); | ||
// Purge unused CSS from the final bundle | ||
const purgecss = require('@fullhuman/postcss-purgecss'); | ||
// Minify CSS | ||
const csso = require('postcss-csso'); | ||
|
||
const BUNDLE = !!process.env.BUNDLE; | ||
|
||
// Looking through all JSX files for selectors | ||
// that are unused in the CSS, and removes the selectors from the final CSS | ||
const purgeCssOpts = { | ||
content: [ | ||
'./src/**/*.{tsx,ts}', | ||
'./node_modules/@lookback/component/build/**/*.js', | ||
// other file paths to template/component code which is | ||
// making use of Lookbook CSS classes. | ||
], | ||
whitelistPatterns: [/flex-\d/, /flex-grow/, /flex-shrink/], | ||
extractors: [ | ||
{ | ||
extractor(content) { | ||
// Matches Tailwind class names | ||
return content.match(/[A-Za-z0-9-_:/]+/g) || []; | ||
}, | ||
|
||
extensions: ['tsx', 'ts'], | ||
}, | ||
], | ||
}; | ||
|
||
module.exports = { | ||
map: !BUNDLE && { | ||
inline: true, | ||
}, | ||
plugins: [ | ||
...defaultPostCssPlugins(), | ||
// Purge unused selectors and minify CSS when bundling | ||
...(BUNDLE ? [purgecss(purgeCssOpts), csso] : []), | ||
// Sending bundle: true to defaultPostCssPlugins() will: | ||
// 1) Purge unused CSS rules. | ||
// 2) Minify the full bundle. | ||
// | ||
// more plugins here.. | ||
...defaultPostCssPlugins({ bundle: BUNDLE }) | ||
// .. and maybe here | ||
], | ||
}; |