vue-theme-loader

A webpack loader for supporting multi-site theming with vue.js
5,826 103
Install
npm install vue-theme-loader
Latest Version:2.0.3
License:MIT
Last Updated:Oct 3, 2019
Links: GitHub  ·  npm
Maintainer: zephraph

vue-theme-loader Greenkeeper badge

A webpack loader for supporting multi-site theming with Vue.js

Give styleblocks in Vue's single file components a theme attribute. Specify which theme you want to build for via an option to vue-theme-loader. All other unmatching themed style blocks will be removed.

In this example there is one non-themed block and two themed. Setting the theme option to brand1 removes the brand2 themed styleblock.

Before

<!-- Vue single component file -->

<style>
  button {
    border: 1px solid black;
  }
</style>

<style theme="brand1">
  button {
    color: red;
  }
</style>

<style theme="brand2">
  button {
    color: blue;
  }
</style>

After (with the theme option set to brand1)

<!-- Vue single component file -->

<style>
  button {
    border: 1px solid black;
  }
</style>

<style theme="brand1">
  button {
    color: red;
  }
</style>

Configuring webpack

It's important to remember that webpack resolves loaders from right to left so vue-theme-loader must always go under vue-loader.

module.exports = {
  module: {
    rules: [
     {
        test: /\.vue$/,
        use: [
          {
            loader: 'vue-loader'
          },
          { 
            loader: 'vue-theme-loader',
            options: {
              theme: 'brand1'
            }
          }
        ]
      }
    ]
  }
};

Related Packages

mpvue-loader

mpvue single-file component loader for Webpack

20,800 46
weex-vue-loader

Vue.js component loader for Webpack

13,557 4,958
chameleon-weex-vue-loader

Vue.js component loader for Webpack

3,418 4,958
cml-vue-loader

Vue single-file component loader for Chameleon

2,626
mpvue-webpack4-loader

mpvue single-file component loader for Webpack

892 0

Version History

Version Released License
2.0.3 MIT
2.0.2 MIT
2.0.1 MIT
2.0.0 MIT
1.2.1 MIT