In Vite2, How to import an ESModule in tailwind.config.js(在VITE2中,如何将ESModule导入到trawind.config.js中)
本文介绍了在VITE2中,如何将ESModule导入到trawind.config.js中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
生成Vite2应用程序。
尝试在tailwind.config.js
中导入ESModule
。
该模块的导出方式如下:
export default xxx;
然后我在tailwind.config.js
Like:
const xx = require('./xx/xxx');
但我收到一个错误:
[plugin:vite:css] Cannot use import statement outside a module
如何修复此问题?
推荐答案
我从维特不和谐频道得到了答复。这是将postcss和tawincss配置文件转换为ES模块的解决方案。
执行此操作,您可以在这些配置文件中使用import
。
trawind.config.js
export default {
purge: ['./*.html', './src/**/*.{vue,js,ts,jsx,tsx,css}'],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
},
variants: {
extend: {},
},
plugins: [],
}
postcss.config.js
import tailwind from 'tailwindcss'
import autoprefixer from 'autoprefixer'
import tailwindConfig from './tailwind.config.js'
export default {
plugins: [tailwind(tailwindConfig), autoprefixer],
}
vite.config.js我添加了import postcss from './postcss.config.js'
和
css: {
postcss,
},
这篇关于在VITE2中,如何将ESModule导入到trawind.config.js中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:在VITE2中,如何将ESModule导入到trawind.config.js中


基础教程推荐
猜你喜欢
- 如何在特定日期之前获取消息? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01