You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
701 B

4 years ago
  1. const qs = require('querystring')
  2. const { compileStyle } = require('@vue/component-compiler-utils')
  3. // This is a post loader that handles scoped CSS transforms.
  4. // Injected right before css-loader by the global pitcher (../pitch.js)
  5. // for any <style scoped> selection requests initiated from within vue files.
  6. module.exports = function (source, inMap) {
  7. const query = qs.parse(this.resourceQuery.slice(1))
  8. const { code, map, errors } = compileStyle({
  9. source,
  10. filename: this.resourcePath,
  11. id: `data-v-${query.id}`,
  12. map: inMap,
  13. scoped: !!query.scoped,
  14. trim: true
  15. })
  16. if (errors.length) {
  17. this.callback(errors[0])
  18. } else {
  19. this.callback(null, code, map)
  20. }
  21. }