index.js
function loader ( module, filePath ) {

    let content = fs.readFileSync(filePath, 'utf8');
    let moduleId = `data-v-${ hash(filePath) }`;

    let vueTemplate = '';
    let vueComponent = compiler.parseComponent(stripBom(content));

    let script = vueComponent.script;
    let styles = vueComponent.styles;
    let template = vueComponent.template;

    let scoped = styles.some(({ attrs }) => attrs.scoped);

    [].concat(script, template, styles).forEach(( tag, index ) => {
        if (tag) {
            let type = tag.type;
            let content = tag.content;
            let lang = tag.attrs.lang || store[type].defaults;
            let handler = store[type].langs[lang];
            if (handler) {
                content = handler(content, filePath, index, module);
            }
            switch (type) {
                case 'style':
                    if (browserEnv) {
                        /**
                         * Only in Browser Environment, append style to head
                         */
                        if (tag.attrs.scoped) {
                            let ast = css.parse(content);
                            ast.stylesheet.rules.forEach(( rule ) => {
                                rule.selectors = rule.selectors.map(( selector ) => {
                                    let [ patterns ] = cssWhat(selector);
                                    let index = patterns.length - 1;
                                    for (; index >= 0; index--) {
                                        let { type } = patterns[index];
                                        if (type !== 'pseudo' && type !== 'pseudo-element') {
                                            break;
                                        }
                                    }
                                    patterns.splice(index + 1, 0, {
                                        value : '',
                                        name : moduleId,
                                        action : 'exists',
                                        type : 'attribute',
                                        ignoreCase : false,
                                    });
                                    return cssWhat.stringify([patterns]);
                                });
                            });
                            content = css.stringify(ast);
                        }
                        let style = document.createElement('style');
                        style.innerHTML = content;
                        store.style.exports.call(module.exports, style, {
                            index,
                            styles,
                            filePath,
                        });
                    }
                    break;
                case 'script':
                    module._compile(content, filePath);
                    break;
                case 'template':
                    if (browserEnv) {
                        /**
                         * Only in Browser Environment, set Attribute for each element
                         */
                        if (scoped) {
                            let div = document.createElement('div');
                            div.innerHTML = content;
                            let root = div.firstElementChild;
                            let walk = function walk ( element, handler ) {
                                handler(element);
                                let children = element.children || [];
                                [].forEach.call(children, ( child ) => {
                                    walk(child, handler);
                                });
                            };
                            walk(root, ( element ) => {
                                element.setAttribute(moduleId, '');
                            });
                            content = div.innerHTML;
                        }
                    }
                    vueTemplate = content;
                    break;
            }
        }
    });

    module.exports.vueComponent = vueComponent;
    module.exports.template = vueTemplate;
}
function loader ( module, filePath ) {

    let content = fs.readFileSync(filePath, 'utf8');
    let moduleId = `data-v-${ hash(filePath) }`;

    let vueTemplate = '';
    let vueComponent = compiler.parseComponent(stripBom(content));

    let script = vueComponent.script;
    let styles = vueComponent.styles;
    let template = vueComponent.template;

    let scoped = styles.some(({ attrs }) => attrs.scoped);

    [].concat(script, template, styles).forEach(( tag, index ) => {
        if (tag) {
            let type = tag.type;
            let content = tag.content;
            let lang = tag.attrs.lang || store[type].defaults;
            let handler = store[type].langs[lang];
            if (handler) {
                content = handler(content, filePath, index, module);
            }
            switch (type) {
                case 'style':
                    if (browserEnv) {
                        /**
                         * Only in Browser Environment, append style to head
                         */
                        if (tag.attrs.scoped) {
                            let ast = css.parse(content);
                            ast.stylesheet.rules.forEach(( rule ) => {
                                rule.selectors = rule.selectors.map(( selector ) => {
                                    let [ patterns ] = cssWhat(selector);
                                    let index = patterns.length - 1;
                                    for (; index >= 0; index--) {
                                        let { type } = patterns[index];
                                        if (type !== 'pseudo' && type !== 'pseudo-element') {
                                            break;
                                        }
                                    }
                                    patterns.splice(index + 1, 0, {
                                        value : '',
                                        name : moduleId,
                                        action : 'exists',
                                        type : 'attribute',
                                        ignoreCase : false,
                                    });
                                    return cssWhat.stringify([patterns]);
                                });
                            });
                            content = css.stringify(ast);
                        }
                        let style = document.createElement('style');
                        style.innerHTML = content;
                        store.style.exports.call(module.exports, style, {
                            index,
                            styles,
                            filePath,
                        });
                    }
                    break;
                case 'script':
                    module._compile(content, filePath);
                    break;
                case 'template':
                    if (browserEnv) {
                        /**
                         * Only in Browser Environment, set Attribute for each element
                         */
                        if (scoped) {
                            let div = document.createElement('div');
                            div.innerHTML = content;
                            let root = div.firstElementChild;
                            let walk = function walk ( element, handler ) {
                                handler(element);
                                let children = element.children || [];
                                [].forEach.call(children, ( child ) => {
                                    walk(child, handler);
                                });
                            };
                            walk(root, ( element ) => {
                                element.setAttribute(moduleId, '');
                            });
                            content = div.innerHTML;
                        }
                    }
                    vueTemplate = content;
                    break;
            }
        }
    });

    module.exports.vueComponent = vueComponent;
    module.exports.template = vueTemplate;
}
Require extension vue hook
@param {Module} module
@param {String} filePath file path
@export {Vue} Vue Component after compile