0

我正在尝试从现已死的 Tachyons 框架迁移到 Tailwindcss。但是,有一个障碍我还没有想出如何克服。

我使用jekyll-postscss Gem 在jekyll build. 以下设置似乎可以很好地工作:

assets/css/styles.css

---
---

@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";

postcss.config.js

module.exports = {
    parser: 'postcss-scss',
    plugins: [
      require('postcss-import'),
      require('tailwindcss'),
      require('autoprefixer'),
      ...(process.env.JEKYLL_ENV == "production"
        ? [require('cssnano')({ preset: 'default' })]
        : [])
    ]
};

tailwind.config.js

module.exports = {
  purge: [
    './_includes/**/*.html',
    './_layouts/**/*.html',
    './_posts/*.md',
    './*.html',
  ],
  darkMode: false,
  theme: {
    extend: {},
  },
  variants: {},
  plugins: [
    require('@tailwindcss/typography'),
  ],
}

使用jekyll build命令,我可以在_site/assets/css.

但是,当我尝试导入其他 css 或 scss 文件时,它不起作用。例如,如果我将styles.css文件修改为以下

assets/css/styles.scss

---
---

@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";

@import "test.css"

where与( )test.css在同一目录中,抛出异常styles.scssassets/css/postcss-import

Error: Failed to find './test.css'
  in [
    /project
  ]
    at /project/node_modules/postcss-import/lib/resolve-id.js:35:13
    at async LazyResult.runAsync (/project/node_modules/postcss/lib/lazy-result.js:396:11)

我有点困惑为什么postcss-import看不到这个文件。

4

0 回答 0