Giter VIP home page Giter VIP logo

vue-loader's Introduction

vue-loader ci

webpack loader for Vue Single-File Components

v17.2.1+ Only Options

  • experimentalInlineMatchResource: boolean: enable Inline matchResource for rule matching for vue-loader.

v16+ Only Options

  • reactivityTransform: boolean: enable Vue Reactivity Transform (SFCs only).

  • refSugar: boolean: removed. use reactivityTransform instead.

  • customElement: boolean | RegExp: enable custom elements mode. An SFC loaded in custom elements mode inlines its <style> tags as strings under the component's styles option. When used with defineCustomElement from Vue core, the styles will be injected into the custom element's shadow root.

    • Default is /\.ce\.vue$/
    • Setting to true will process all .vue files in custom element mode.
  • enableTsInTemplate: boolean (16.8+): allow TS expressions in templates when <script> has lang="ts". Defaults to true.

    • When used with ts-loader, due to ts-loader's cache invalidation behavior, it sometimes prevents the template from being hot-reloaded in isolation, causing the component to reload despite only the template being edited. If this is annoying, you can set this option to false (and avoid using TS expressions in templates).

    • Alternatively, leave this option on (by default) and use esbuild-loader to transpile TS instead, which doesn't suffer from this problem (it's also a lot faster). However, do note you will need to rely on TS type checking from other sources (e.g. IDE or vue-tsc).

What is Vue Loader?

vue-loader is a loader for webpack that allows you to author Vue components in a format called Single-File Components (SFCs):

<template>
  <div class="example">{{ msg }}</div>
</template>

<script>
export default {
  data() {
    return {
      msg: 'Hello world!',
    }
  },
}
</script>

<style>
.example {
  color: red;
}
</style>

There are many cool features provided by vue-loader:

  • Allows using other webpack loaders for each part of a Vue component, for example Sass for <style> and Pug for <template>;
  • Allows custom blocks in a .vue file that can have custom loader chains applied to them;
  • Treat static assets referenced in <style> and <template> as module dependencies and handle them with webpack loaders;
  • Simulate scoped CSS for each component;
  • State-preserving hot-reloading during development.

In a nutshell, the combination of webpack and vue-loader gives you a modern, flexible and extremely powerful front-end workflow for authoring Vue.js applications.

How It Works

The following section is for maintainers and contributors who are interested in the internal implementation details of vue-loader, and is not required knowledge for end users.

vue-loader is not a simple source transform loader. It handles each language blocks inside an SFC with its own dedicated loader chain (you can think of each block as a "virtual module"), and finally assembles the blocks together into the final module. Here's a brief overview of how the whole thing works:

  1. vue-loader parses the SFC source code into an SFC Descriptor using @vue/compiler-sfc. It then generates an import for each language block so the actual returned module code looks like this:

    // code returned from the main loader for 'source.vue'
    
    // import the <template> block
    import render from 'source.vue?vue&type=template'
    // import the <script> block
    import script from 'source.vue?vue&type=script'
    export * from 'source.vue?vue&type=script'
    // import <style> blocks
    import 'source.vue?vue&type=style&index=1'
    
    script.render = render
    export default script

    Notice how the code is importing source.vue itself, but with different request queries for each block.

  2. We want the content in script block to be treated like .js files (and if it's <script lang="ts">, we want to to be treated like .ts files). Same for other language blocks. So we want webpack to apply any configured module rules that matches .js also to requests that look like source.vue?vue&type=script. This is what VueLoaderPlugin (src/plugins.ts) does: for each module rule in the webpack config, it creates a modified clone that targets corresponding Vue language block requests.

    Suppose we have configured babel-loader for all *.js files. That rule will be cloned and applied to Vue SFC <script> blocks as well. Internally to webpack, a request like

    import script from 'source.vue?vue&type=script'

    Will expand to:

    import script from 'babel-loader!vue-loader!source.vue?vue&type=script'

    Notice the vue-loader is also matched because vue-loader are applied to .vue files.

    Similarly, if you have configured style-loader + css-loader + sass-loader for *.scss files:

    <style scoped lang="scss">

    Will be returned by vue-loader as:

    import 'source.vue?vue&type=style&index=1&scoped&lang=scss'

    And webpack will expand it to:

    import 'style-loader!css-loader!sass-loader!vue-loader!source.vue?vue&type=style&index=1&scoped&lang=scss'
  3. When processing the expanded requests, the main vue-loader will get invoked again. This time though, the loader notices that the request has queries and is targeting a specific block only. So it selects (src/select.ts) the inner content of the target block and passes it on to the loaders matched after it.

  4. For the <script> block, this is pretty much it. For <template> and <style> blocks though, a few extra tasks need to be performed:

    • We need to compile the template using the Vue template compiler;
    • We need to post-process the CSS in <style scoped> blocks, after css-loader but before style-loader.

    Technically, these are additional loaders (src/templateLoader.ts and src/stylePostLoader.ts) that need to be injected into the expanded loader chain. It would be very complicated if the end users have to configure this themselves, so VueLoaderPlugin also injects a global Pitching Loader (src/pitcher.ts) that intercepts Vue <template> and <style> requests and injects the necessary loaders. The final requests look like the following:

    // <template lang="pug">
    import 'vue-loader/template-loader!pug-loader!source.vue?vue&type=template'
    
    // <style scoped lang="scss">
    import 'style-loader!vue-loader/style-post-loader!css-loader!sass-loader!vue-loader!source.vue?vue&type=style&index=1&scoped&lang=scss'

vue-loader's People

Contributors

amour1688 avatar chen-jj avatar danielroe avatar h-a-n-a avatar heywhy avatar jamie-yang avatar jinjiang avatar juniortour avatar linusborg avatar merceyz avatar meteorlxy avatar miixc avatar mvorisek avatar nolimitdev avatar peckzeg avatar rstoenescu avatar sevilyilmaz avatar silverwind avatar simonsiefke avatar sodatea avatar thecrypticace avatar weaverryan avatar xanf avatar yyx990803 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-loader's Issues

Remove loaders this plugin depends on.

What do you think about removing dependencies on babel-loader and autoprefixer?
I mean, I'll probably use babel-loader and autoprefixer in all my projects, but shouldn't it be something I add to the loader chain myself? 😛

why require does not work inside .vue file?

My application has directories as following:

App
/node_modules
/components/mobile/a.vue
/b.vue

with such dirs, I can use require in b.vue to use node module inside node_modules, but it fails when I try to use require in a.vue , webpack will report module not found. what is wrong? thanks!

Problem configuring `scss` lang for stylesheets

I'm trying to define a "custom" lang for scss, so it'll use the sass-loader for <style lang='scss'>, but can't manage to make it work.

This is the vue section in my webpack.config:

module.exports = {
    ...
    vue: {
        loaders: {
            scss: 'sass'
    }
}

And this is the error:

ERROR in ./~/sass-loader!./~/vue-loader/lib/style-rewriter.js!./~/vue-loader/lib/selector.js?type=style&index=0!./src/vue/app.vue
Module build failed: TypeError: undefined is not a function
    at Object.module.exports (/Users/sdavidson/Development/bring/node_modules/sass-loader/index.js:211:17)

Am I missing adding pipes to the scss loader?

How to process the relative src in the <img> tag

when I use the relative src in the tag just like below:

<img class="abs" src="media/V2.0_home_Kits1.1.png">

when compile the vue, it will report err, like

ERROR in ./~/html-loader!./~/vue-loader/lib/selector.js?type=template&index=0!./app/src/views/letsGuessIndexView.vue
Module not found: Error: Cannot resolve 'file' or 'directory' ./V2.0_home_Kits1.1.png in /Users/mingxinzhou/Documents/LetsCake-LetsGuess/app/src/views
 @ ./~/html-loader!./~/vue-loader/lib/selector.js?type=template&index=0!./app/src/views/letsGuessIndexView.vue 1:261-295

image

how should I deal with

Can't load .vue after update babel to 6.0.0

ERROR in .//babel-loader?optional[]=runtime&loose=all&nonStandard=false!.//vue-loader/lib/selector.js?type=script&index=0!./src/js/components/header/header.vue
Module build failed: ReferenceError: [BABEL] /Users/gaozepan/Documents/youmeiba/node_modules/vue-loader/lib/selector.js?type=script&index=0!/Users/gaozepan/Documents/youmeiba/src/js/components/header/header.vue: Unknown option: base.optional
at Logger.error (/Users/gaozepan/Documents/youmeiba/node_modules/babel-core/lib/transformation/file/logger.js:43:11)
at OptionManager.mergeOptions (/Users/gaozepan/Documents/youmeiba/node_modules/babel-core/lib/transformation/file/options/option-manager.js:244:18)
at OptionManager.init (/Users/gaozepan/Documents/youmeiba/node_modules/babel-core/lib/transformation/file/options/option-manager.js:395:10)
at File.initOptions (/Users/gaozepan/Documents/youmeiba/node_modules/babel-core/lib/transformation/file/index.js:191:75)
at new File (/Users/gaozepan/Documents/youmeiba/node_modules/babel-core/lib/transformation/file/index.js:122:22)
at Pipeline.transform (/Users/gaozepan/Documents/youmeiba/node_modules/babel-core/lib/transformation/pipeline.js:42:16)
at transpile (/Users/gaozepan/Documents/youmeiba/node_modules/babel-loader/index.js:12:22)
at Object.module.exports (/Users/gaozepan/Documents/youmeiba/node_modules/babel-loader/index.js:69:12)
@ ./src/js/components/header/header.vue 2:17-169

//package.json
{
"version": "1.0.0",
"main": "webpack.config.js",
"dependencies": {
"babel-loader": "^6.0.0",
"babel-runtime": "^6.0.14",
"css-loader": "^0.21.0",
"extract-text-webpack-plugin": "^0.8.2",
"file-loader": "^0.8.4",
"style-loader": "^0.13.0",
"url-loader": "^0.5.6",
"underscore": "^1.8.3",
"vue": "^1.0.3",
"vue-html-loader": "^1.0.0",
"vue-loader": "^6.0.1",
"webpack": "^1.12.2",
"vue-validator": "^1.4.4",
"vue-hot-reload-api": "^1.2.1"
},
"devDependencies": {
"babel-core": "^6.0.14",
"babel-loader": "^6.0.0",
"babel-preset-es2015": "^6.0.14"
},
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"author": "",
"license": "ISC",
"description": ""
}

Can't use eslint-loader with vue-loader

I think I either need access to the js portion's preloader or else I think eslint clobbers the stream and babel doesn't know what to do with it.

eslint-loader usage

webpack.config.js:

var path = require('path')

module.exports = {
    name: 'client',
    target: 'web',
    entry: {
      'bundle': './src/client/scripts/app.js',
    },
    output: {
      path: path.resolve('dist'),
      filename: '[name].js'
    },
    module: {
      preLoaders: [
        {
          test: /\.jsx?$/,
          exclude: /node_modules/,
          loader: 'eslint',
        },
      ],
      loaders: [
        {
          test: /\.jsx?$/,
          exclude: /node_modules/,
          loader: 'babel'
        },
        {
          test: /\.vue$/,
          loader: 'vue'
        }
      ]
    },
    eslint: {
      configFile: './.eslint'
    },
    vue: {
      loaders: {
        js: 'babel!eslint?{rules:{eol-last:0}}'
      }
    },
    devtool: '#source-map'
  }

App.vue:

<template>
  <h1 class="red">{{msg}}</h1>
</template>

<script>
export default {
  props: [
    'msg'
  ]
}
</script>

<style>
  .red {
    color: #f00;
  }
</style>

output:

ERROR in ./~/babel-loader!./~/eslint-loader?{rules:{eol-last:0}}!./~/vue-loader/lib/selector.js?type=script&index=0!./src/client/scripts/components/App.vue
Module build failed: SyntaxError: Expected ':' instead of '-'
    at JSON5.parse.error (C:\Users\Danny\Dev\gland\node_modules\eslint-loader\node_modules\loader-utils\node_modules\json5\lib\json5.js:50:25)
    at JSON5.parse.next (C:\Users\Danny\Dev\gland\node_modules\eslint-loader\node_modules\loader-utils\node_modules\json5\lib\json5.js:62:17)
    at JSON5.parse.object (C:\Users\Danny\Dev\gland\node_modules\eslint-loader\node_modules\loader-utils\node_modules\json5\lib\json5.js:443:21)
    at JSON5.parse.value (C:\Users\Danny\Dev\gland\node_modules\eslint-loader\node_modules\loader-utils\node_modules\json5\lib\json5.js:467:20)
    at JSON5.parse.object (C:\Users\Danny\Dev\gland\node_modules\eslint-loader\node_modules\loader-utils\node_modules\json5\lib\json5.js:444:35)
    at JSON5.parse.value (C:\Users\Danny\Dev\gland\node_modules\eslint-loader\node_modules\loader-utils\node_modules\json5\lib\json5.js:467:20)
    at Object.parse (C:\Users\Danny\Dev\gland\node_modules\eslint-loader\node_modules\loader-utils\node_modules\json5\lib\json5.js:491:18)
    at Object.parseQuery (C:\Users\Danny\Dev\gland\node_modules\eslint-loader\node_modules\loader-utils\index.js:54:16)
    at Object.module.exports (C:\Users\Danny\Dev\gland\node_modules\eslint-loader\index.js:111:17)

 @ ./src/client/scripts/components/App.vue 2:17-147

Module build failed: TypeError: this._init is not a function

vue-strap is a vuecomponent , and i want to use it like this:

require('vue-strap').alert

but it report errors below:

Module build failed: TypeError: this._init is not a function
at Object.Vue (E:\vue\vue-strap1\node_modules\vue-strap\node_modules\vue\src
\vue.js:19:8)

the code in the vue-strap/src/main.js file:

var _AlertVue = require('./Alert.vue');

exports.alert = _AlertVue;

Multiple styles lang not supported

Only one style tag and lang per .vue file is support. Be nice to support any number of styles/lang per .vue page.

e.g.

<style lang="stylus">
body
  color yellow
</style>

<style lang="less">
 body {
  background: blue;
 }
</style>

will only return an output containing the second ("less") style tag contents and not incorporate the first ("stylus") style contents.

Component scoped style is not applied to the upper level element

Suppose we have a component like this:

<template>
  <section>
    <p>I am content</p>
  </section>
</template>
<style scoped>
  section { background: white }
  p {color: black}
</style>

After being loaded, it results in html and css like this:

<section class="v-58ec653c">
  <p>I am content</p>
</section>
<style type="text/css">
.v-58ec653c section {
    background: white;
}
.v-58ec653c p {
    color: black
}
</style>

For obvious reasons, .v-58ec653c section is not being applied.

Recommendation: Change element order in example to <style> <template> <script>

I'd recommend to change the order of the example on https://github.com/vuejs/vue-loader from <template> <script> <style> to <style> <template> <script>. It would be in line with http://vuejs.org/guide/application.html and is also easier to work with, as both <style> and <script> are working with the <template> section of a .vue file. If you have <template> on the top and <style> on the bottom, you always have to jump over <script> if you're working on styling the template.

I've only realized this just now and am starting to change the orders of all of my .vue files, after having originally started with the order given in the example.

Incorrectly translate the included resources in the HTML template

For example, suppose we have a .vue file as follows

<template>
  <div><img src="img/logo.png">{{company}}</div>
</template>
<script>
module.exports = {
  data: {
    company: "My Company"
  }
};
</script>

Use the webpack with vue-loader to compile this file will cause an error: it said that the ".png" file is not recognizable. It seems the vue-loader tries to translate the resources in the HTML template into a "require" command, which is incorrect.

A temporal solution is to use the "v-attr" directive,

<template>
  <div><img v-attr="src:'img/logo.png'">{{company}}</div>
</template>

Use webpack loaders to load included files

You say "note you'll have to save the vue file to trigger a rebuild since the imported file is not tracked by Browserify as a dependency". (I guess you mean webpack instead of Browserify)

I really would like a fix for this. Is it not possible to use the webpack loaders to load included files, so the included files are tracked as well?

Getting error with latest vue-loader when compiling the build

ERROR in ./~/babel-loader?presets[]=es2015&plugins[]=transform-runtime!./~/vue-loader/lib/selector.js?type=script&index=0!./src/main.vue
Module build failed: ReferenceError: [BABEL] /home/thelinuxlich/aidax-client-graphs/node_modules/vue-loader/lib/selector.js?type=script&index=0!/home/thelinuxlich/aidax-client-graphs/src/main.vue: Unknown option: direct.presets

Component style should be scoped to component

All styles are currently in the global scope, it would be great if the vue-loader could generate unique identifiers for components. So something like this.

<style>
   .profile{ }
   .profile__picture{ }
</style>
<template>
   <div class="profile">
       <img class="profile__picture" />
   </div>
</template>
[...]

Would be transformed to:

<style>
   .uniqueID--profile{ }
   .uniqueID--profile__picture{ }
</style>
<template>
   <div class="uniqueID--profile">
       <img class="uniqueID--profile__picture" />
   </div>
</template>
[...]

Jade error when used with vue-loader

Environment: latest vue beta, jade template in .vue file. When trying to instantiate a component from that file, Vue shows a warning:

[Vue warn]: Invalid template option: function template(locals)

As far as I understand, it's because Jade loader returns a function that evaluates to the template text, not template string. It looks like a check if the template is a function is required somewhere in this file: https://github.com/vuejs/vue-loader/blob/master/lib/loader.js

@media goes wrong when lang="stylus"

If change this example's b.vue's style content to:

<style lang="stylus" scoped>
.container
  border: 1px solid #f00
h2
  color: #393;
@media print
  .foo
    color: #000
</style>

and run the npm run build
will get the error below:

ERROR in ./~/css-loader!./~/vue-loader/lib/style-rewriter.js!./~/stylus-loader!./~/vue-loader/lib/selector.js?type=style&index=0!./src/components/b.vue
Module build failed: TypeError: Cannot read property 'valueOf' of undefined
    at tokenize (/Users/Pan/Documents/Js/js framework/Vue/vue-loader-example/node_modules/vue-loader/node_modules/postcss-selector-parser/dist/tokenize.js:34:24)
    at new Parser (/Users/Pan/Documents/Js/js framework/Vue/vue-loader-example/node_modules/vue-loader/node_modules/postcss-selector-parser/dist/parser.js:89:49)
    at Processor.process (/Users/Pan/Documents/Js/js framework/Vue/vue-loader-example/node_modules/vue-loader/node_modules/postcss-selector-parser/dist/processor.js:36:25)
    at /Users/Pan/Documents/Js/js framework/Vue/vue-loader-example/node_modules/vue-loader/lib/style-rewriter.js:15:10
    at Root.each (/Users/Pan/Documents/Js/js framework/Vue/vue-loader-example/node_modules/vue-loader/node_modules/postcss/lib/container.js:89:22)
    at /Users/Pan/Documents/Js/js framework/Vue/vue-loader-example/node_modules/vue-loader/lib/style-rewriter.js:8:10
    at LazyResult.run (/Users/Pan/Documents/Js/js framework/Vue/vue-loader-example/node_modules/vue-loader/node_modules/postcss/lib/lazy-result.js:197:24)
    at /Users/Pan/Documents/Js/js framework/Vue/vue-loader-example/node_modules/vue-loader/node_modules/postcss/lib/lazy-result.js:110:37
    at LazyResult.asyncTick (/Users/Pan/Documents/Js/js framework/Vue/vue-loader-example/node_modules/vue-loader/node_modules/postcss/lib/lazy-result.js:124:15)
    at processing.Promise.then._this2.processed (/Users/Pan/Documents/Js/js framework/Vue/vue-loader-example/node_modules/vue-loader/node_modules/postcss/lib/lazy-result.js:150:20)
    at LazyResult.async (/Users/Pan/Documents/Js/js framework/Vue/vue-loader-example/node_modules/vue-loader/node_modules/postcss/lib/lazy-result.js:147:27)
    at LazyResult.then (/Users/Pan/Documents/Js/js framework/Vue/vue-loader-example/node_modules/vue-loader/node_modules/postcss/lib/lazy-result.js:72:21)
    at Object.module.exports (/Users/Pan/Documents/Js/js framework/Vue/vue-loader-example/node_modules/vue-loader/lib/style-rewriter.js:26:6)
 @ ./~/style-loader!./~/css-loader!./~/vue-loader/lib/style-rewriter.js!./~/stylus-loader!./~/vue-loader/lib/selector.js?type=style&index=0!./src/components/b.vue 4:14-240

Is this a bug or my bad?

Hot Module Replacement

Is there a way to use the Hot Module Replacement having my component split into three files (JS, HTML and CSS)?

I ask this because I'd really love to keep the Atom's linters working on my code... Thanks.

miss postcss-loader in css dialect

for example:

<!-- main.vue -->

<style lang="sass">
  body {display: flex;}
</style>

<style>
  body {display: flex;}
</style>
  • webpack loader config: { test: /\.vue$/, loader: vue.withLoaders({css: 'style!css!postcss-loader'})}
  • postcss config: postcss: function () {return {defaults: [autoprefixer]}}

and the different bundle:

"body {\n  display: flex; }\n"
"body {display: -webkit-box;display: -webkit-flex;display: -ms-flexbox;display: flex;}"

Seems like the sass code not processed by postcss-loader

npm run build error on Windows 10

I run the command npm run build on cmd,
it said error, I change the package.json

"build": "set NODE_ENV=production&& webpack --progress --hide-modules"

then it's OK, wish u fix it~

Excluding Section of HTML

I found a odd issue with vue-loader where it would exclude a section of html for no odd reason, with no warnings or errors from webpack. No matter what I change, even if i remove the whole section, anything in the 'content' div does not show up. If i remove the content from the container div then that div shows up, but if no matter what i add or remove, it would be excluded from the js file when bundling it with webpack.

<template>
    <div class="masthead">
        <div class="container">
            <h1 class="masthead-subtitle">
            Contact Us
          </h1>
        </div>
    </div>
    <div class="content">
    <!-- Anything below is not excluded from the js file-->
        <div class="container">
            <div class="layout layout-stack-sm layout-main-left">
                <div class="col-sm-8 layout-main">
                    <div class="heading-block">
                        <h4>Get in Touch</h4>
                    </div>

                    <h4><span id="message"></span></h4>
                    <br/>
                    <br/>

                    <form class="form form-horizontal" method="post" v-on="submit:contactus">
                        <div class="form-group">
                            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
                                <label>Name: <span class="required">*</span></label>
                                <input class="form-control" id="name" name="name" type="text" v-model="name" />
                            </div>

                            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
                                <label>Email: <span class="required">*</span></label>
                                <input class="form-control" type="email" id="email" name="email" v-model="email" />
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                                <label>Subject: <span class="required">*</span></label>
                                <input class="form-control" id="subject" name="subject" type="text" v-model="subject" />
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                                <label>Message: <span class="required">*</span></label>
                                <textarea class="form-control" id="text" name="text" rows="6" cols="40" v-model="message" />
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                                <button class="btn btn-primary" type="submit">Send Message</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</template>

I could never find out why this is so, and i decided to give up and submit an issue regarding this. It does not happen to any other page so im wondering if something is triggering it. Maybe a bad syntax that vue-loader doesnt like, but im not to sure.

请问为啥.vue文件里必须是vueOptions对象,而不能是Vue.extend({})的class?

Hi 哥们,
我这里把vue和webpack组合,cmd的模块加载机制。
我看loader里定义的.vue里面是vueOptions对象,但我们的模块都写成了 module.exports = Vue.extend({}); 这样的类,我可能还会拦截里面的created事件什么的,请问哪种是推荐的做法?
因为vue loader现在的机制我没法定义viewmodel class的模块了

vue.withLoaders not work?

I follow ES6 with Babel example in readme, and installed babel-runtime.But get Object.assign is not a function in vue file.

var vue = require('vue-loader')

module.exports = {
  // entry, output...
  module: {
    loaders: [
      {
        test: /\.vue$/,
        loader: vue.withLoaders({
          // apply babel transform to all javascript
          // inside *.vue files.
          js: 'babel?optional[]=runtime'
        })
      }
    ]
  },
  devtool: 'source-map'
}

Then I tried writing <script lang="babel?optional[]=runtime>" in vue file, and it worked

Nested routes cannot work correctly with webpack + vue-loader+vue-router

Hi

I take this repo(https://github.com/OpenSISE/game-app) as the example to build up my new website.
But I found that when I try to setup the nested routes, it cannot render the template.
eg:

'/user': {
      // component: require('./views/user.vue'),
      subRoutes: {
        '/register': {
            component: require('./views/user/register.vue')
        },
        '/login': {
            component: require('./views/user/login.vue')
        }
}```
But if I define a new route like ```    
'/test/register': {
     component: require('./views/user/register.vue')
 }```
it can work and render this nested page.

It's my first time using Vuejs. Thanks.

webpack-dev-server --hot Error: Module not found

Hi. Can you speak Chinese? : )

下面是场景:
dev-env:win7 x64
node-version:v4.2.0
cmd:webpack-dev-server --hot
error info: ERROR in ./src/components/a.vue
Module not found: Error: Cannot resolve module 'E:
odewwwdevspaceapp
ode_modules�ue-loaderlibhot-reload-api.js' in E:\nodewww\devspace\app\src\compon
ents
@ ./src/components/a.vue 6:13-93

经分析发现是转义符的问题..

@./libs/loader.js 中的 141行:

'var hotAPI = require("' + require.resolve('./hot-reload-api') + '")\n' +
替换成:
'var hotAPI = require("' + require.resolve('./hot-reload-api').replace(/\/g, "\\") + '")\n' +

就ok了.. 第一次反馈问题,说的有点混乱。

框架很好用,谢谢。

How can I get access to current template?

I want to create component which extends another one:

<script>
var table = require('../../../components').datatable

module.exports = table.extend({
   template: ?
})
</script>

<template>
...
</template>

How can I get access to current template?

The problem of include Jade file with vue-loader

Here is my Vue component structure:

<template lang="jade">
include index.jade
</template>

<style lang="less">
@import "index.less";
</style>

<script>
</script>

When the index.jade file changes,webpack-dev-server will not automatically compile code, there is no good solution to it?

do not support .sass files very well

<style lang="scss">
  body {
    margin: 0
  }
</style>

and

<style lang="sass">
  body
    margin: 0
</style>

do not work, but

<style lang="sass">
  body {
    margin: 0
  }
</style>

does.

And directly using sass-loader is well. both .scss and .sass files:

require('!style!css!sass?indentedSyntax!./foo.sass')
require('!style!css!sass!./foo.scss')

Unmet dependencies

I'm afraid some dependencies are missing :

$ npm install --save-dev vue-loader
/Users/loranger/Developer/projects/fairechier
├── UNMET PEER DEPENDENCY css-loader@*
├── UNMET PEER DEPENDENCY style-loader@*
├── UNMET PEER DEPENDENCY vue-html-loader@^1.0.0
└─┬ [email protected]
  ├── [email protected]
  ├─┬ [email protected]
  │ └── [email protected]
  ├── [email protected]
  ├── [email protected]
  └─┬ [email protected]
    ├── [email protected]
    ├── [email protected]
    └── [email protected]

npm WARN EPEERINVALID [email protected] requires a peer of vue-html-loader@^1.0.0 but none was installed.
npm WARN EPEERINVALID [email protected] requires a peer of css-loader@* but none was installed.
npm WARN EPEERINVALID [email protected] requires a peer of style-loader@* but none was installed.

Did I miss something ?

有在windows下测试过loader是否可用吗

项目初始是在mac下构建的,一切正常,但是同事在windows下就不能正常构建了,显示错误信息为

ERROR in ./src/admin/views/404.vue
Module not found: Error: Cannot resolve 'file' or 'directory' ./../../../node_modules/vue-loader/lib/selector.js in C:\usr\assert/src\admin\views
@ ./src/admin/views/404.vue 1:26-130

ERROR in ./src/admin/views/home/index.vue
Module not found: Error: Cannot resolve 'file' or 'directory' ./../../../../node_modules/vue-loader/lib/selector.js in C:\usr\assert/src\admin\views\home
@ ./src/admin/views/home/index.vue 1:17-140

Problems with ExtractTextPlugin on SCSS

Extraction of CSS works absolutely OK.
But when I use "lang='sass'" I get this:

ERROR in ./~/extract-text-webpack-plugin/loader.js?{"remove":true}!./~/css-loader!./~/sass-loader!./~/vue-loader/lib/style-rewriter.js!./~/vue-loader/lib/selector.js?type=style&index=0!./src/App/app.vue
Module build failed: TypeError: content.trim is not a function
    at Object.module.exports (D:\OpenServer\domains\test.dev\node_modules\sass-loader\index.js:211:17)
 @ ./src/App/app.vue 1:0-229

My webpack.config.js:

var webpack = require('webpack'),
    path = require('path'),
    BowerPlugin = require('bower-webpack-plugin'),
    ExtractTextPlugin = require('extract-text-webpack-plugin');

var EXCLUDE = /node_modules|bower_components/;

module.exports = {
    context: path.resolve('src'),
    entry: './index.js',
    output: {
        path: path.resolve('dist'),
        publicPath: '/dist/',
        filename: 'scripts-bundle.min.js'
    },
    module: {
        preLoaders: [
            {
                test: /\.js$/,
                loader: 'eslint',
                exclude: EXCLUDE
            }
        ],
        loaders: [
            {
                test: /\.js$/,
                loader: 'babel',
                exclude: EXCLUDE
            },
            {
                test: /\.scss$/,
                loader: ExtractTextPlugin.extract('style', 'css!autoprefixer!sass'),
                exclude: EXCLUDE
            },
            {
                test: /\.less$/,
                loader: ExtractTextPlugin.extract('style', 'css!autoprefixer!less'),
                exclude: EXCLUDE
            },
            {
                test: /\.css/,
                loader: ExtractTextPlugin.extract('style', 'css!autoprefixer'),
                exclude: EXCLUDE
            },
            {
                test: /\.html$/,
                loader: 'raw',
                exclude: EXCLUDE
            },
            {
                test: /\.vue$/,
                loader: 'vue',
                exclude: EXCLUDE
            }
        ]
    },
    eslint: {
        configFile: path.resolve('.eslintrc')
    },
    babel: {
        optional: ['runtime'],
        loose: 'all',
        nonStandard: false,
        stage: 0
    },
    vue: {
        loaders: {
            css: ExtractTextPlugin.extract('css'),
            scss: ExtractTextPlugin.extract('css!sass')
        }
    },
    autoprefixer: {
        browsers: ['last 2 versions']
    },
    plugins: [
        new BowerPlugin,
        new ExtractTextPlugin('styles-bundle.min.css')
    ],
    watch: true,
    devtool: "source-map"
};

Tested css extraction on "vue-loader-example". The same problem. Here is config:

var webpack = require('webpack'),
    ExtractText = require('extract-text-webpack-plugin');

module.exports = {
  entry: './src/main.js',
  output: {
    path: './dist',
    publicPath: '/dist/',
    filename: 'build.js'
  },
  module: {
    loaders: [
      {
        test: /\.vue$/,
        loader: 'vue'
      }
    ]
  },
  vue: {
    loaders: {
      css: ExtractText.extract('css'),
      stylus: ExtractText.extract('css!stylus')
    }
  },
  plugins: [
    new ExtractText('build.css')
  ]
}

if (process.env.NODE_ENV === 'production') {
  module.exports.plugins = [
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: '"production"'
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false
      }
    }),
    new webpack.optimize.OccurenceOrderPlugin()
  ]
} else {
  module.exports.devtool = '#source-map'
}

Thanx in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.