WIP - add extractor, generate snippet_data

This commit is contained in:
Stefan Fejes
2019-08-20 15:52:05 +02:00
parent 88084d3d30
commit cc8f1d8a7a
37396 changed files with 4588842 additions and 133 deletions

6
node_modules/url-loader/dist/cjs.js generated vendored Normal file
View File

@ -0,0 +1,6 @@
'use strict';
const loader = require('./index');
module.exports = loader.default;
module.exports.raw = loader.raw;

77
node_modules/url-loader/dist/index.js generated vendored Normal file
View File

@ -0,0 +1,77 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.raw = undefined;
exports.default = loader;
var _loaderUtils = require('loader-utils');
var _schemaUtils = require('schema-utils');
var _schemaUtils2 = _interopRequireDefault(_schemaUtils);
var _mime = require('mime');
var _mime2 = _interopRequireDefault(_mime);
var _normalizeFallback = require('./utils/normalizeFallback');
var _normalizeFallback2 = _interopRequireDefault(_normalizeFallback);
var _options = require('./options.json');
var _options2 = _interopRequireDefault(_options);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// Loader Mode
const raw = exports.raw = true; /* eslint-disable
global-require,
no-param-reassign,
prefer-destructuring,
import/no-dynamic-require,
*/
function loader(src) {
// Loader Options
const options = (0, _loaderUtils.getOptions)(this) || {};
(0, _schemaUtils2.default)(_options2.default, options, 'URL Loader');
const file = this.resourcePath;
// Set limit for resource inlining (file size)
let limit = options.limit;
if (limit) {
limit = parseInt(limit, 10);
}
// Get MIME type
const mimetype = options.mimetype || _mime2.default.getType(file);
// No limit or within the specified limit
if (!limit || src.length < limit) {
if (typeof src === 'string') {
src = Buffer.from(src);
}
return `module.exports = ${JSON.stringify(`data:${mimetype || ''};base64,${src.toString('base64')}`)}`;
}
// Normalize the fallback.
const {
loader: fallbackLoader,
options: fallbackOptions
} = (0, _normalizeFallback2.default)(options.fallback, options);
// Require the fallback.
const fallback = require(fallbackLoader);
// Call the fallback, passing a copy of the loader context. The copy has the query replaced. This way, the fallback
// loader receives the query which was intended for it instead of the query which was intended for url-loader.
const fallbackLoaderContext = Object.assign({}, this, {
query: fallbackOptions
});
return fallback.call(fallbackLoaderContext, src);
}

40
node_modules/url-loader/dist/options.json generated vendored Normal file
View File

@ -0,0 +1,40 @@
{
"type": "object",
"properties": {
"limit": {
"type": ["string", "number"]
},
"mimetype": {
"type": "string"
},
"fallback": {
"anyOf": [
{
"type": "string"
},
{
"additionalProperties": false,
"properties": {
"loader": {
"description": "Fallback loader name",
"type": "string"
},
"options": {
"description": "Fallback loader options",
"anyOf": [
{
"type": "object"
},
{
"type": "string"
}
]
}
},
"type": "object"
}
]
}
},
"additionalProperties": true
}

View File

@ -0,0 +1,38 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = normalizeFallback;
var _loaderUtils = require('loader-utils');
var _loaderUtils2 = _interopRequireDefault(_loaderUtils);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function normalizeFallback(fallback, originalOptions) {
let loader = 'file-loader';
let options = {};
if (typeof fallback === 'string') {
loader = fallback;
const index = fallback.indexOf('?');
if (index >= 0) {
loader = fallback.substr(0, index);
options = _loaderUtils2.default.parseQuery(fallback.substr(index));
}
}
if (fallback !== null && typeof fallback === 'object') {
({ loader, options } = fallback);
}
options = Object.assign({}, originalOptions, options);
delete options.fallback;
return { loader, options };
}