node package manager
Don’t reinvent the wheel. Reuse code within your team. Create a free org »



npm version Build Status

This module compile a single file Vue component like the one below into a CommonJS module that can be used in Browserify/Webpack/Component/Duo builds.

Currently supported preprocessors are:

  • stylus
  • less
  • scss (via node-sass)
  • jade
  • coffee-script
  • myth
  • es6 (via 6to5 aka babel)

Also see Registering Custom Pre-Processors.


// app.vue
  .red {
    color: #f00;
  <h1 class="red">{{msg}}</h1>
  module.exports = {
    data: function () {
      return {
        msg: 'Hello world!'

You can also mix preprocessor languages in the component file:

// app.vue
<style lang="stylus">
  color #f00
<template lang="jade">
<script lang="coffee">
module.exports =
  data: ->
    msg: 'Hello world!'

And you can import using the src attribute:

<style lang="stylus" src="style.styl"></style>
<template src="template.html"></template>
<script src="./scripts/main.js"></script>


var compiler = require('vue-component-compiler')
// filePath should be an absolute path, and is optional if 
// the fileContent doesn't contain src imports 
compiler.compile(fileContent, filePath, function (err, result) {
  // result is a common js module string 

Registering Custom Pre-Processors

Create a vue.config.js file at where your build command is run (usually the root level of your project):

module.exports = function (compiler) {
  // register a compile function for <script lang="es"> 
    lang: 'es',
    type: 'script',
    compile: function (content, cb) {
      // transform the content... 
      cb(null, content)