heritage-hub/postcss.config.js

32 lines
1003 B
JavaScript
Raw Normal View History

2024-02-01 11:49:57 +00:00
import postcss from 'postcss';
2024-02-01 10:54:28 +00:00
import pxToViewport from 'postcss-px-to-viewport';
2024-02-01 11:49:57 +00:00
import { customPostCSSPlugin } from "./src/utils/custom-postcss-plugin.js"; // 替换为实际的路径
// 将 pxToViewport 应用到 navigation 文件夹下的文件
const customPxToViewportPlugin = postcss.plugin('custom-px-to-viewport', (options) => {
const pxToViewportInstance = pxToViewport({
viewportWidth: options.viewportWidth,
// ... 其他 pxToViewport 参数,如果需要的话
});
return (root, result) => {
const file = result.opts.from;
// 确保路径中包含 navigation 文件夹
if (file && file.includes('navigation')) {
pxToViewportInstance(root, result);
}
};
});
2024-02-01 10:54:28 +00:00
export default {
plugins: [
2024-02-01 11:49:57 +00:00
customPostCSSPlugin({
// ... 你的自定义插件选项
}),
customPxToViewportPlugin({
2024-02-01 10:54:28 +00:00
viewportWidth: 1920,
}),
2024-02-01 11:49:57 +00:00
// ... 其他通用 PostCSS 插件
],
2024-02-01 10:54:28 +00:00
};