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.0 to 0.2.1

lib/modules/add-scoped-id.js

23

package.json
{
"name": "vue-template-loader",
"version": "0.2.0",
"version": "0.2.1",
"description": "Vue.js 2.0 template loader for webpack",
"main": "lib/index.js",
"main": "lib/template-loader.js",
"files": [

@@ -26,8 +26,13 @@ "lib"

"scripts": {
"test": "jasmine JASMINE_CONFIG_PATH=test/jasmine.json"
"example": "webpack --config example/webpack.config.js",
"lint": "eslint lib test",
"test": "npm run lint && jasmine JASMINE_CONFIG_PATH=test/jasmine.json",
"prepublish": "npm run test"
},
"dependencies": {
"postcss": "^5.2.8",
"postcss-selector-parser": "^2.2.2",
"vue-hot-reload-api": "^2.0.6",
"vue-template-compiler": "^2.1.6",
"vue-template-es2015-compiler": "^1.4.0"
"vue-template-compiler": "^2.1.8",
"vue-template-es2015-compiler": "^1.4.2"
},

@@ -39,9 +44,13 @@ "devDependencies": {

"babel-register": "^6.18.0",
"css-loader": "^0.26.1",
"eslint": "^3.12.2",
"eslint-config-ktsn": "^1.0.0",
"jasmine": "^2.5.2",
"loader-utils": "^0.2.16",
"require-from-string": "^1.2.1",
"vue": "^2.1.6",
"vue-class-component": "^4.4.0"
"style-loader": "^0.13.1",
"vue": "^2.1.8",
"vue-class-component": "^4.4.0",
"webpack": "^2.2.0-rc.3"
}
}

@@ -12,2 +12,3 @@ # vue-template-loader

- Insert a render function to a component options object
- vue-loader like scoped css and css modules support
- HMR support for a template

@@ -18,2 +19,4 @@ - Decorator syntax support (can be used with [vue-class-component](https://github.com/vuejs/vue-class-component) or other class style components)

### Loading Template
Just add a loader option for vue-template-loader to your webpack configuration.

@@ -24,4 +27,4 @@

module: {
loaders: [
{ test: /\.html$/, loader: 'vue-template-loader' }
rules: [
{ test: /\.html$/, use: 'vue-template-loader' }
]

@@ -32,2 +35,45 @@ }

### Loading Scoped Styles
You need to specify scoped flag and loaders for style files such as `style-loader` and `css-loader`. Note that they must be `enforce: post` to inject scope id into styles before they are processed by them.
```js
module.exports = {
module: {
rules: [
{
test: /\.html$/,
use: 'vue-template-loader?scoped' // add `scoped` flag
},
{
enforce: 'post', // required
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
}
}
```
### Loading CSS Modules
All what you have to do is enable `modules` flag of `css-loader`. vue-template-loader will add `$style` property and you can use hashed classes through it.
```js
module.exports = {
module: {
rules: [
{
test: /\.html$/,
use: 'vue-template-loader'
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader?modules'] // Enable CSS Modules
}
]
}
}
```
## Example

@@ -45,7 +91,7 @@

Import it as a function and pass a component option to the function.
Import it as a function and pass a component option to the function. If you also would like to load a style file, add `style` query and specify the style file path.
```js
// app.js
import withRender from './app.html'
import withRender from './app.html?style=./app.css'

@@ -91,4 +137,4 @@ export default withRender({

interface WithRender {
(options: Vue.ComponentOptions<Vue>): Vue.ComponentOptions<Vue>
(component: typeof Vue): typeof Vue
<V extends Vue>(options: Vue.ComponentOptions<V>): Vue.ComponentOptions<V>
<V extends typeof Vue>(component: V): V
}

@@ -95,0 +141,0 @@ const withRender: WithRender

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