Skip to content

Commit

Permalink
Merge pull request #14 from ktsn/bump
Browse files Browse the repository at this point in the history
Use getOptions instead of parseQuery
  • Loading branch information
ktsn committed Mar 7, 2017
2 parents 94c911c + 8e4152a commit ea66e5b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lib/scoped-style-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const addScopedId = require('./modules/add-scoped-id')
module.exports = function (rawStyle) {
this.cacheable()
const cb = this.async()
const { id } = loaderUtils.parseQuery(this.query)
const { id } = loaderUtils.getOptions(this)

assert(id)

Expand Down
13 changes: 11 additions & 2 deletions lib/template-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ module.exports = function (content) {
const id = `data-v-${genId(this.resourcePath)}`

// Acquire the query of target file
const { style: stylePath } = loaderUtils.parseQuery('?' + this.request.split('?').pop())
const options = loaderUtils.parseQuery(this.query)
const { style: stylePath } = parseQuery(this.request.split('?').pop())
const options = loaderUtils.getOptions(this) || {}

const compiled = compile(content, options)
compiled.errors.forEach(error => {
Expand Down Expand Up @@ -95,3 +95,12 @@ function writeHotReloadCode (id) {
'})()}\n'
].join('\n')
}

function parseQuery (query) {
const res = {}
query.replace(/^\?/, '').split('&').forEach(param => {
const p = param.split('=')
res[p[0]] = p[1] || true
})
return res
}
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,26 @@
"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.8",
"vue-template-es2015-compiler": "^1.4.2"
"loader-utils": "^1.0.3",
"postcss": "^5.2.15",
"postcss-selector-parser": "^2.2.3",
"vue-hot-reload-api": "^2.0.11",
"vue-template-compiler": "^2.2.1",
"vue-template-es2015-compiler": "^1.5.1"
},
"devDependencies": {
"babel-eslint": "^7.1.1",
"babel-plugin-transform-class-properties": "^6.19.0",
"babel-plugin-transform-class-properties": "^6.23.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-register": "^6.18.0",
"css-loader": "^0.26.1",
"eslint": "^3.12.2",
"babel-register": "^6.23.0",
"css-loader": "^0.26.2",
"eslint": "^3.17.1",
"eslint-config-ktsn": "^1.0.0",
"jasmine": "^2.5.2",
"loader-utils": "^0.2.16",
"jasmine": "^2.5.3",
"require-from-string": "^1.2.1",
"style-loader": "^0.13.1",
"vue": "^2.1.8",
"vue-class-component": "^4.4.0",
"webpack": "^2.2.0-rc.3"
"style-loader": "^0.13.2",
"vue": "^2.2.1",
"vue-class-component": "^5.0.0",
"webpack": "^2.2.1"
}
}

0 comments on commit ea66e5b

Please sign in to comment.