首页 > 解决方案 > VuePress:如何导入 css 框架(basscss)

问题描述

我正在尝试将basscssVuePress项目一起使用,并且不确定如何在不直接引用 mode_modules 中的文件的情况下正确包含 basscss 文件,并且希望避免使用第三方 CDN。

到目前为止,我已经安装了带有 yarn 和一些 postcss 插件的 basscss 并制作了我自己的主题:

.vuepress
├── node_modules
├── package.json
└── theme
    ├── Layout.vue
    └── styles
        └── theme.styl

在我的config.js

module.exports = {
  postcss: {
    plugins: [
      require('postcss-import')
    ]
  }
  ...
}

Layout.vue<style src="./styles/theme.styl" lang="stylus"></style>

theme.style@import "basscss.css"这会导致错误:

模块构建失败(来自 /Users/user/.config/yarn/global/node_modules/postcss-loader/lib/index.js):错误:在 [ /Users/user/code/project_title 中找不到“basscss.css” /.vuepress/theme/styles ]

使用标准的 webpack 模板很容易做到vue-cli,但我在 VuePress 上苦苦挣扎,因为我不太熟悉 webpack 在这种特殊情况下的运作方式。

标签: webpackvuepress

解决方案


推荐阅读