Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-template-loader

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-template-loader - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

lib/modules/template-compiler.js

18

lib/template-loader.js

@@ -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 @@ {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc