ktsn / vue-template-loader

Vue.js 2.0 template loader for webpack
MIT License
266 stars 26 forks source link

Set scoped=true/false in require statement #19

Closed Toilal closed 7 years ago

Toilal commented 7 years ago

It would be great to allow setting scoped property on a template basis, inside the import statement.

I think something like this could do the trick:

import viewRender from './component.html?scoped=false&style=component.css'
ktsn commented 7 years ago

Hmm, I actually want to keep this query trick as minimum as possible since this seems to be non-standard implementation. Also this can be complex and unreadable code easily if we allow more options for that place.

What is the use case of this option? I personally think, it would be enough to use plain style-/css-loader if we want non-scoped style.

Toilal commented 7 years ago

I see.

My idea is to have as much as possible the same capabilities that when using .vue single-file components with vue-loader. It's used to emulate the scoped attribute of <style> tag from single-file components.

ktsn commented 7 years ago

I've rethought about this but I still have no idea of valid usage. It looks clearer just importing .css files directly if we want non-scoped styles. And I think we can cover the vue-loader's functionality with such approach.

Import css files directly:

import withRender from './template.html'
import './global.css'

Introducing scoped on query:

import withRender from './template.html?scoped=true&./global.css'

So I'm closing this issue. Thanks for your suggestion and PR, though!