Releases: ktsn/vue-template-loader
v1.1.0
v1.0.0
v0.4.1
v0.4.0
v0.3.1
v0.3.0
v0.2.4
v0.2.3
v0.2.2
New
-
Add
transformToRequire
option.
The option allows us to transform asset path in template torequire
expression as same as vue-loader.Example configuration:
rules: [ { test: /\.html$/, loader: 'vue-template-loader', options: { transformToRequire: { img: 'src' } } } ]
v0.2.1
New
-
Allow to load a css file via query
You can load a css file with template by specifying the file path via query. the css file will be processed by loaders that you specified in webpack config as same as ordinary webpack behavior.
// ./style.css will be loaded import template from './template.html?style=./style.css'
-
Support vue-loader like scoped styles and CSS Modules
If you enable
scoped
flag of vue-template-loader, all styles loaded by query will be scoped like vue-loader. That means unique attribute (likedata-v-123
) will be added all css selectors and html elements. Note that you have to addenforce: 'post'
into rules for style files.module.exports = { module: { rules: [ { test: /\.html$/, use: 'vue-template-loader?scoped' // add `scoped` flag }, { enforce: 'post', // required test: /\.css$/, use: ['style-loader', 'css-loader'] } ] } }
If you prefer to use CSS Modules, you can use it by just adding
modules
flag to css-loader's query. vue-template-loader will add$style
property that has hashed classes and you can refer it from a template.module.exports = { module: { rules: [ { test: /\.html$/, use: 'vue-template-loader' }, { test: /\.css$/, use: ['style-loader', 'css-loader?modules'] // Enable CSS Modules } ] } }
<p :class="$style.foo">Hello</p>