grunt-requirejs-vue-component-registration

0.1.2 • Public • Published

grunt-requirejs-vue-component-registration

Create vue component config for async loading with requirejs

Getting Started

This plugin requires Grunt ~0.4.5

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-requirejs-vue-component-registration --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-requirejs-vue-component-registration');

The "requirejsVueComponentRegistration" task

Overview

Create vue component config for async loading with requirejs.

grunt.initConfig({
    requirejsVueComponentRegistration: {
        options: {
            files: ['pathToVueFiles/**/*.vue'],
            basePath: 'basePathToVueFiles',
            targetFile: 'basePathToVueFiles/registerComponents.js'
        }
    }
});

targetFile output:

define([
    "Vue"
], function(Vue) {

    /**
     * register vue components for async loading
     */

    return (function() {

        function registerComponents() {

            Vue.component('nice-component', function (resolve, reject) {
                require(["vue!/Components/niceComponent"], function(component) {
                    resolve(component);
                });
            });

        }

        return registerComponents();
	});
});

Release History

  • Big bang

Readme

Keywords

Package Sidebar

Install

npm i grunt-requirejs-vue-component-registration

Weekly Downloads

0

Version

0.1.2

License

none

Unpacked Size

117 kB

Total Files

22

Last publish

Collaborators

  • danisahni