Can't use CommonJS require
in Vite (which is ES6), but can't seem to use import
either as the build process complains that you cannot use import from outside a module
(tailwind.config.js)
const colors = require('tailwindcss/colors') // throws error that require is CommonJS
import colors from 'tailwindcss/colors' // throws error: cannot import from outside a module
module.exports = {
purge: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'],
darkMode: false, // or 'media' or 'class'
theme: {
colors: {
gray: colors.coolGray,
teal: colors.teal,
green: colors.green,
cyan: colors.cyan,
blue: colors.lightBlue,
indigo: colors.indigo,
white: colors.white
},
extend: {},
},
variants: {
extend: {},
},
plugins: [
]
}
Help appreciated...
question from:
https://stackoverflow.com/questions/65850146/vite-tailwind-import-colors-js-into-tailwind-config-js 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…