【发布时间】:2022-02-04 10:10:17
【问题描述】:
我通过npm init vue@latest 使用 Vite 创建了一个新的 Vue 应用程序。我基于the official guide在项目中添加了TailwindCSS。
运行npm run lint 会抛出错误
error 'module' is not defined no-undef
因为它希望 postcss.config.js 和 tailwind.config.js 成为 ES 模块(我认为)。
从
转换postcss.config.js时module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
到
export const plugins = {
tailwindcss: {},
autoprefixer: {},
};
和 tailwind.config.js 来自
module.exports = {
content: ["./index.html", "./src/**/*.{vue,js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
};
到
export const content = ["./index.html", "./src/**/*.{vue,js,ts,jsx,tsx}"];
export const theme = {
extend: {},
};
export const plugins = [];
并运行 npm run dev 应用程序崩溃并出现错误
[vite] 内部服务器错误:意外的令牌“导出” 插件:vite:css
如何解决这个 linting 错误?
【问题讨论】:
-
你为什么要这样做?您使用的工具是否在其配置中支持 ESM?我建议不要使用与您的代码相同的规则对配置文件进行 linting。
-
为什么?它会增加什么价值?也许这可能会有所帮助:stackoverflow.com/questions/45854169/…?
-
ok 其他问题:您将如何解决此 linting 错误? linting 时忽略这些文件?
-
没错,你为什么要检查配置文件呢?请记住,这些文件是配置工具。可能有一些价值,但我认为现在你应该忽略它们
标签: javascript vue.js eslint tailwind-css