stylePostLoader.js 701 B

1234567891011121314151617181920212223
  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. }