Vuepress: Support for pre-processors in .vuepress/components

Created on 19 Apr 2018  路  4Comments  路  Source: vuejs/vuepress

Is there a way to get VuePress to support pre-processors like pug and sass?

good first issue

Most helpful comment

We should add built-in config for pug and document this in the config section.

All 4 comments

Good question, thanks!

For using pug and sass at you custom component, you need to do following things:

  1. Install essential dependencies:
yarn add sass-loader node-sass -D # for sass
yarn add pug-plain-loader pug -D # for pug

Since config for scss, sass, stylus, less has been built in VuePress, you ONLY need to extend for pug at your .vuepress/config.js:

module.exports = {
  chainWebpack: config => {
    config.module
      .rule('pug')
      .test(/\.pug$/)
      .use('pug-plain-loader')
        .loader('pug-plain-loader')
        .end()
  }
}

Then you can create a custom component (e.g. Pug.vue) at .vuepress/components:

<template lang="pug">
  p.pug {{ msg }}
</template>

<script>
  export default {
    data () {
      return {
        msg: 'Hello, Pug'
      }
    }
  }
</script>

<style lang="sass">
  .pug
    font-size: 20px
</style>

Enjoy your writing!

We should add built-in config for pug and document this in the config section.

Wonderful! That worked.

I don't know if this is worth documenting as well, but I wasn't entirely sure whether I should install the dependencies within the .vuepress folder or (the correct way) from the root of my project, which makes package.json, node_modules, and .vuepress siblings.

fixed at #151 and docs are here: https://vuepress.vuejs.org/guide/using-vue.html#using-pre-processors

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tinchox5 picture tinchox5  路  3Comments

cfjedimaster picture cfjedimaster  路  3Comments

zeke picture zeke  路  3Comments

AleksejDix picture AleksejDix  路  3Comments

sankincn picture sankincn  路  3Comments