PostCSS plugin and import globs #586
-
I'm trying to combine Lume and it's PostCSS plugin with a custom includes directory and support for import globs (using the Here's how I've got the PostCSS plugin configured: import postcss from "lume/plugins/postcss.ts";
import postcssImport from "npm:postcss-import";
import postcssImportExtGlob from "npm:postcss-import-ext-glob";
import postcssPresetEnv from "npm:postcss-preset-env";
import postcssReporter from "npm:postcss-reporter";
import postcssUrl from "npm:postcss-url";
// […]
site.use(postcss({
includes: "/assets/css/", // trailing slash is required
plugins: [
postcssImportExtGlob(), // must be placed before `postcss-import`
postcssImport({
plugins: [
stylelint()
]
}),
postcssUrl,
postcssPresetEnv({ stage: 0 }), // polyfill all features
postcssReporter({ clearReportedMessages: true })
],
useDefaultPlugins: false,
})); Note that where I've set my includes folder, I've had to use a trailing slash. Removing this mean that no CSS got copied to the _site directory at all, which was surprising and took me a little time to figure out. I've got a main stylesheet @import "_reset.css";
@import-glob "components/*.css"; All the files I'd like to include are in subdirectories of With this setup, the imported file However, the line If I remove the How can I get the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Lume automatically use the postcssImport if the site.use(postcss({
includes: false, // disable the postcss-import plugin
plugins: [
postcssImportExtGlob(), // must be placed before `postcss-import`
postcssImport({
plugins: [
stylelint()
]
}),
postcssUrl,
postcssPresetEnv({ stage: 0 }), // polyfill all features
postcssReporter({ clearReportedMessages: true })
],
useDefaultPlugins: false,
})); Keep in mind that an imported file doesn't prevent the file to be also copied to the output. If you don't want the files in site.ignore("/assets/css"); |
Beta Was this translation helpful? Give feedback.
Lume automatically use the postcssImport if the
includes
option is defined.If the glob plugin must be defined before, you must disable the includes option, so this plugin is not added automatically:
Keep in mind that an imported file doesn't pre…