如何在 Svelte 中删除 PostCSS 生成的空样式?

时间:2021-06-13 09:22:30

标签: svelte postcss

我在我的 svelte 上使用 Vite + PostCSS 设置,但不知何故它生成了一个空样式。有没有办法删除它,还是我的设置搞砸了?

PostCSS with empty style

vite.config.js 设置

import { defineConfig } from 'vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';

export default defineConfig({
  plugins: [svelte()],
});

svelte.config.js 设置

const sveltePreprocess = require('svelte-preprocess');

module.exports = {
  preprocess: [
    sveltePreprocess({
      postcss: true,
    }),
  ],
};

postcss.config.js 设置(这里有 tailwindcss 和 autoprefixer,但删除它们并不能解决问题)

const config = {
  plugins: [],
};

module.exports = config;

App.svelte 示例

<main>
  <img src="{logo}" alt="Svelte Logo" />
  <h1>Hello Typescript!</h1>
</main>

<script lang="ts">
import logo from './assets/svelte.png';
</script>

<style lang="postcss">
h1 {
  color: green;
}

</style>

0 个答案:

没有答案