我有一个Vue web组件。当我将它构建为一个普通的Vue组件时,一切都很好。然而,它失去了所有的Tailwind样式,我立即将它转换为Vue Web组件。谢谢你提前帮忙。
tailwind.config.js
module.exports = {
content: [
"./index.html",
"./src/**/*.{vue,js,ts,jsx,tsx}",
],
theme: {
extend: {
colors: {
},
},
},
plugins: [
],
}tailwind.css
@tailwind base;
@tailwind components;
@tailwind utilities;还有我的vite.config.js
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue({
template: {
compilerOptions: {
// treat all tags with a dash as custom elements
isCustomElement: (tag) => tag.includes('-')
}
}
})],
build: {
lib: {
entry: './src/entry.js',
formats: ['es','cjs'],
name: 'web-component',
fileName: (format)=>(format === 'es' ? 'index.js' : 'index.cjs')
},
sourcemap: true,
target: 'esnext',
minify: false
}
})发布于 2022-04-11 06:52:21
无论如何,就目前而言,我所做的就是将Tailwind直接添加到web组件中,并且它可以工作。
<style>
@import url("../tailwind.css");
</style>https://stackoverflow.com/questions/71810799
复制相似问题