NOTE: this loader only works with Webpack
npm install vue-features-loader
Within your Webpack config:
...
loaders: [
{
test: /\.vue$/,
loader: 'vue!vue-features'
},
...
],
...
var define = require('vue-features-loader/define')
/* Here are your feature toggles */
var features = {
AWESOME_FEATURE: true,
FEATURE_IN_DEVELOPMENT: isProduction() ? false : true,
...
}
module.exports = {
features,
defines: define(features)
}
feed your feature toggles to vue-features-loader for use with Vue templates.
Within your Webpack config:
var feature = require('./features')
...
plugins: [
new webpack.DefinePlugin({
'features': feature.defines
}),
],
vueFeatures: feature.features
...
...
if (features.AWESOME_FEATURE) {
// your code when AWESOME_FEATURE is turned on
}
...
...
<on feature="FEATURE_IN_DEVELOPMENT">
<p>This should only show up if the FEATURE_IN_DEVELOPMENT is turned on.</p>
</on>
<off feature="FEATURE_IN_DEVELOPMENT">
<p>This should only show up if the FEATURE_IN_DEVELOPMENT is turned off.</p>
</off>
...