简体   繁体   English

错误:[object Object] 不是 PostCSS 插件

[英]Error: [object Object] is not a PostCSS plugin

This is my postcss configuration code in rollup.config.js file:这是我在 rollup.config.js 文件中的 postcss 配置代码:

const postcssUrlOpts = [
    {
        url: 'copy',
        filter: /\.woff$/,
        assetsPath: 'font'
    }
];

const postcssOpts = {
    extract: 'index.css',
    plugins: [
        postcssUrl(postcssUrlOpts)
    ]
};

And this is the log that I get:这是我得到的日志:

Error: [object Object] is not a PostCSS plugin
    at Processor.normalize (/.../node_modules/rollup-plugin-postcss/node_modules/postcss/lib/processor.es6:130:15)
    at new Processor (/.../node_modules/rollup-plugin-postcss/node_modules/postcss/lib/processor.es6:38:25)
    at postcss (/.../node_modules/rollup-plugin-postcss/node_modules/postcss/lib/postcss.es6:34:10)
    at /.../node_modules/rollup-plugin-postcss/dist/index.js:213:28
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/.../node_modules/rollup-plugin-postcss/dist/index.js:19:24)
    at _next (/.../node_modules/rollup-plugin-postcss/dist/index.js:41:9)

Without postcssUrl plugin all my css imports in javascript files are working and everything is fine but when I add this plugin to the list of postcss plugins I get this error in my console.如果没有 postcssUrl 插件,我在 javascript 文件中的所有 css 导入都可以正常工作,一切都很好,但是当我将此插件添加到 postcss 插件列表时,我在控制台中收到此错误。 Any other plugin like tailwindcss plugin works just fine.任何其他插件,如 tailwindcss 插件都可以正常工作。

versions:版本:

postcss: ^8.1.10
postcss-url: ^10.1.1

The elements of the plugins array should be functions. plugins数组的元素应该是函数。 You're calling the function immediately and returning the object.您立即调用 function 并返回 object。 Wrap the function call in a function.将 function 调用包装在 function 中。

const postcssOpts = {
    extract: 'index.css',
    plugins: [
        () => postcssUrl(postcssUrlOpts)
    ]
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:PostCSS 插件 tailwindcss 需要 PostCSS 8 - Error: PostCSS plugin tailwindcss requires PostCSS 8 错误:PostCSS 插件 tailwindcss 需要 PostCSS 8(更新 v2 到 v3) - Error: PostCSS plugin tailwindcss requires PostCSS 8(update v2 to v3) JQuery 插件错误:对象 [object Object] 没有方法“test” - JQuery plugin error : Object [object Object] has no method 'test' X [错误] [plugin esbuild-style-plugin] E:\...\postcss.config.js 的 PostCSS 配置文件无法加载 - X [ERROR] [plugin esbuild-style-plugin] PostCSS config file at E:\...\postcss.config.js can't load 如何将 postcss.plugin 迁移到 postCSS 8 格式 - How to migrate postcss.plugin to postCSS 8 format postcss 和 simple-vars - 使用 object 中的变量 - postcss and simple-vars - use variables that are inside an object 由于 postcss 和 css-minimizer-webpack-plugin 上的 CSS minimzer 出现“未知词”错误,Gatsby Build 失败 - Gatsby Build failed because of "Unknown Word' Error from CSS minimzer on postcss and css-minimizer-webpack-plugin Tailwind CSS(PostCSS 插件)与 Next.js 10.0.3 在 dev 环境中给出 Javascript 堆出 ZCD298B4957F080DE8 错误 - Tailwind CSS (PostCSS Plugin) with Next.js 10.0.3 gives Javascript heap out of memory error in dev environment 引用插件中的插件对象 - refer to the plugin object within the plugin JavaScript插件-面向对象? - javascript plugin - object oriented?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM