Skip to content

Support for pre-processors in .vuepress/components #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aminimalanimal opened this issue Apr 19, 2018 · 4 comments
Closed

Support for pre-processors in .vuepress/components #146

aminimalanimal opened this issue Apr 19, 2018 · 4 comments
Labels
good first issue Good for newcomers

Comments

@aminimalanimal
Copy link

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

@ulivz
Copy link
Member

ulivz commented Apr 19, 2018

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!

@ulivz ulivz added the good first issue Good for newcomers label Apr 19, 2018
@yyx990803
Copy link
Member

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

@aminimalanimal
Copy link
Author

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.

@ulivz
Copy link
Member

ulivz commented Apr 25, 2018

@ulivz ulivz closed this as completed Apr 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants