svelte - 将 Autoprefixer 添加到 Svelte & Parcel 项目?

标签 svelte postcss parcel autoprefixer

我似乎无法让 autoprefixerParcelSvelte 一起工作。我在 'svelte.config.js' 文件中有以下代码,但它似乎没有工作,即使它没有抛出任何错误。 Sass 正在正确编译,我有一个 .browserlistrc 文件。任何帮助将不胜感激!

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

module.exports = {
  preprocess: sveltePreprocess({
    scss: true,  
    postcss: {
        plugins: [require('autoprefixer')]
    }
  })
};

我安装了以下 devDependencies

  "devDependencies": {
    "autoprefixer": "^9.7.3",
    "parcel-bundler": "^1.12.4",
    "parcel-plugin-svelte": "^4.0.5",
    "postcss": "^7.0.26",
    "postcss-load-config": "^2.1.0",
    "sass": "^1.24.2",
    "svelte": "^3.16.5",
    "svelte-preprocess": "^3.3.0"
  }

最佳答案

svelte.config.js 适用于编辑器 - 更具体的语言服务器,不适用于您的 rollup 工具。查看文档here

  1. postcss.config.js
module.exports = {
  plugins: {
    autoprefixer: {}
  }
}
  1. .browserslistrc
> 1%

运行 npm run devnpm run build 后,您将在您的 css 文件中看到这些供应商前缀,或者您可以在浏览器中查看。

关于svelte - 将 Autoprefixer 添加到 Svelte & Parcel 项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59643900/

相关文章:

svelte - 访问 svelte 中的 URL 查询字符串

javascript - 如何上传 Sveltekit 多个文件

使用 Kotlin @Parcelize 解码时的 Android 10 BadParcelableException ClassNotFoundException

javascript - 在 Rollup 构建的 Electron 应用程序中导入 Ramda 会导致错误

javascript - svelte:svelte 如何在 if block 之间运行函数?

javascript - create-react-app 中的 CSS 链接

带有 less 和 postcss autoprefixer 的 webpack

javascript - PostCSS 中匹配断点的正则表达式

android - 尝试使用 onSaveInstanceState() 恢复 String[][] 时出现 "java.lang.NullPointerException: Attempt to get length of null array"

android - 如何在 Kotlin 1.1.60 中使用@Parcelize?