【发布时间】:2022-11-08 01:48:03
【问题描述】:
我有一个 Vue Web 组件。当我将它构建为普通的 Vue 组件时,一切正常。但是,当我将其转换为 Vue Web 组件时,它立即失去了所有 Tailwind 样式。提前感谢您的帮助。
tailwind.config.js
module.exports = {
content: [
"./index.html",
"./src/**/*.{vue,js,ts,jsx,tsx}",
],
theme: {
extend: {
colors: {
},
},
},
plugins: [
],
}
顺风.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
}
})
【问题讨论】:
标签: vue.js tailwind-css web-component