Is there a way to get VuePress to support pre-processors like pug and sass?
Good question, thanks!
For using pug and sass at you custom component, you need to do following things:
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
Most helpful comment
We should add built-in config for pug and document this in the config section.