【问题标题】:Eslint error in postcss.config at vue-clivue-cli 的 postcss.config 中的 Eslint 错误
【发布时间】:2020-06-05 14:27:01
【问题描述】:

我已经开始了一个新的 vue-cli 项目

vue create -n tailwind-demo

? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, TS, PWA, Vuex, Linter
? Use class-style component syntax? Yes
? Use Babel alongside TypeScript (required for modern mode, auto-detected polyfills, transpiling JSX)? Yes
? Pick a linter / formatter config: Prettier
? Pick additional lint features: Lint on save, Lint and fix on commit
? Where do you prefer placing config for Babel, ESLint, etc.? In dedicated config files

我还添加了以下postcss.config.js

module.exports = {
  plugins: [
    require("postcss-preset-env")({ stage: 0 }),
    require("tailwindcss")(),
    require("autoprefixer")()
  ]
};

当我运行 yarn lint 命令时,出现以下错误

error: Require statement not part of import statement (@typescript-eslint/no-var-requires) at postcss.config.js:3:5:
error: Require statement not part of import statement (@typescript-eslint/no-var-requires) at postcss.config.js:4:5:
error: Require statement not part of import statement (@typescript-eslint/no-var-requires) at postcss.config.js:5:5:

如何导入插件或如何在 Vue CLI 中为 postcss.config.js 配置 eslint?

我尝试过类似的东西

import tailwindCss from "tailwindcss";

但我在构建时收到了SyntaxError: Unexpected identifier

【问题讨论】:

    标签: vue.js vue-cli postcss


    【解决方案1】:

    它似乎适用于以下postcss.config.js

    module.exports = {
      plugins: {
        "postcss-preset-env": {
          stage: 0
        },
        tailwindcss: {}
      }
    };
    

    【讨论】:

      猜你喜欢
      • 2018-12-14
      • 2020-10-27
      • 2019-01-23
      • 2020-01-25
      • 2019-06-22
      • 2016-12-09
      • 2019-12-17
      • 2018-11-23
      • 2021-02-13
      相关资源
      最近更新 更多