stylePostLoader.js 962 B

1234567891011121314151617181920212223242526
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const qs = require("querystring");
  4. const compiler_1 = require("./compiler");
  5. // This is a post loader that handles scoped CSS transforms.
  6. // Injected right before css-loader by the global pitcher (../pitch.js)
  7. // for any <style scoped> selection requests initiated from within vue files.
  8. const StylePostLoader = function (source, inMap) {
  9. const query = qs.parse(this.resourceQuery.slice(1));
  10. const { code, map, errors } = compiler_1.compiler.compileStyle({
  11. source: source,
  12. filename: this.resourcePath,
  13. id: `data-v-${query.id}`,
  14. map: inMap,
  15. scoped: !!query.scoped,
  16. trim: true,
  17. isProd: this.mode === 'production' || process.env.NODE_ENV === 'production',
  18. });
  19. if (errors.length) {
  20. this.callback(errors[0]);
  21. }
  22. else {
  23. this.callback(null, code, map);
  24. }
  25. };
  26. exports.default = StylePostLoader;