index.js 845 B

12345678910111213141516171819202122232425
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = rawLoader;
  6. var _loaderUtils = require("loader-utils");
  7. var _schemaUtils = _interopRequireDefault(require("schema-utils"));
  8. var _options = _interopRequireDefault(require("./options.json"));
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10. function rawLoader(source) {
  11. const options = (0, _loaderUtils.getOptions)(this);
  12. (0, _schemaUtils.default)(_options.default, options, {
  13. name: 'Raw Loader',
  14. baseDataPath: 'options'
  15. });
  16. const json = JSON.stringify(source).replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
  17. const esModule = typeof options.esModule !== 'undefined' ? options.esModule : true;
  18. return `${esModule ? 'export default' : 'module.exports ='} ${json};`;
  19. }