PostCSS
PostCSS is a popular CSS transpiler with support for a huge ecosystem of plugins.
To use PostCSS with Snowpack: Install @snowpack/plugin-postcss, PostCSS, and your PostCSS plugins, then add this plugin to your Snowpack config.
// snowpack.config.mjs
export default {
+ plugins: ['@snowpack/plugin-postcss'],
};
Lastly, add a postcss.config.js
file. By default, @snowpack/plugin-postcss looks for this in the root directory of your project, but you can customize this with the config
option. See the plugin README for all available options.
// postcss.config.js
module.exports = {
plugins: [
// Replace below with your plugins
require('cssnano'),
require('postcss-preset-env'),
],
};
Be aware that this plugin will run on all CSS in your project, including any files that compiled to CSS (like .scss
Sass files).