vue-template-loader
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -8,4 +8,3 @@ /** | ||
const loaderUtils = require('loader-utils') | ||
const compiler = require('vue-template-compiler') | ||
const transpile = require('vue-template-es2015-compiler') | ||
const compile = require('./modules/template-compiler') | ||
const genId = require('./modules/gen-id') | ||
@@ -16,3 +15,2 @@ | ||
const isServer = this.options.target === 'node' | ||
const compiled = compiler.compile(content) | ||
const id = `data-v-${genId(this.resourcePath)}` | ||
@@ -22,4 +20,5 @@ | ||
const { style: stylePath } = loaderUtils.parseQuery('?' + this.request.split('?').pop()) | ||
const { scoped } = loaderUtils.parseQuery(this.query) | ||
const options = loaderUtils.parseQuery(this.query) | ||
const compiled = compile(content, options) | ||
compiled.errors.forEach(error => { | ||
@@ -29,7 +28,2 @@ this.emitError('template syntax error ' + error) | ||
const transpiled = transpile( | ||
`var render = ${toFunction(compiled.render)}\n` + | ||
`var staticRenderFns = [${compiled.staticRenderFns.map(toFunction).join(',')}]` | ||
) | ||
const shouldHotReload = !isServer && | ||
@@ -39,3 +33,3 @@ !this.minimize && | ||
let output = writeRenderCode(transpiled, id, stylePath, scoped) | ||
let output = writeRenderCode(compiled.code, id, stylePath, options.scoped) | ||
if (shouldHotReload) { | ||
@@ -109,5 +103,1 @@ output += writeHotReloadCode(id) | ||
} | ||
function toFunction (code) { | ||
return `function(){${code}}` | ||
} |
{ | ||
"name": "vue-template-loader", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Vue.js 2.0 template loader for webpack", | ||
@@ -5,0 +5,0 @@ "main": "lib/template-loader.js", |
@@ -32,2 +32,35 @@ # vue-template-loader | ||
### Asserts Handling | ||
You can transform an asset path in template to `require` expression that the webpack can handle. For example, if you would like to process image file specified on `src` attributes of `<img>` element, you should set `transformToRequire` option. | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.html$/, | ||
loader: 'vue-template-loader', | ||
options: { | ||
transformToRequire: { | ||
// The key should be element name, | ||
// the value should be attribute name or its array | ||
img: 'src' | ||
} | ||
} | ||
}, | ||
// Make sure to add the loader that can process the asset files | ||
{ | ||
test: /\.(png|jpg)/, | ||
loader: 'file-loader', | ||
options: { | ||
// ... | ||
} | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
### Loading Scoped Styles | ||
@@ -43,3 +76,6 @@ | ||
test: /\.html$/, | ||
use: 'vue-template-loader?scoped' // add `scoped` flag | ||
loader: 'vue-template-loader', | ||
options: { | ||
scoped: true // add `scoped` flag | ||
} | ||
}, | ||
@@ -46,0 +82,0 @@ { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
12439
8
192
179
0