настройка webpack
This commit is contained in:
38
node_modules/css-loader/dist/CssSyntaxError.js
generated
vendored
Normal file
38
node_modules/css-loader/dist/CssSyntaxError.js
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
class CssSyntaxError extends Error {
|
||||
constructor(error) {
|
||||
super(error);
|
||||
const {
|
||||
reason,
|
||||
line,
|
||||
column
|
||||
} = error;
|
||||
this.name = 'CssSyntaxError'; // Based on https://github.com/postcss/postcss/blob/master/lib/css-syntax-error.es6#L132
|
||||
// We don't need `plugin` and `file` properties.
|
||||
|
||||
this.message = `${this.name}\n\n`;
|
||||
|
||||
if (typeof line !== 'undefined') {
|
||||
this.message += `(${line}:${column}) `;
|
||||
}
|
||||
|
||||
this.message += `${reason}`;
|
||||
const code = error.showSourceCode();
|
||||
|
||||
if (code) {
|
||||
this.message += `\n\n${code}\n`;
|
||||
} // We don't need stack https://github.com/postcss/postcss/blob/master/docs/guidelines/runner.md#31-dont-show-js-stack-for-csssyntaxerror
|
||||
|
||||
|
||||
this.stack = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = CssSyntaxError;
|
||||
32
node_modules/css-loader/dist/Warning.js
generated
vendored
Normal file
32
node_modules/css-loader/dist/Warning.js
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
class Warning extends Error {
|
||||
constructor(warning) {
|
||||
super(warning);
|
||||
const {
|
||||
text,
|
||||
line,
|
||||
column
|
||||
} = warning;
|
||||
this.name = 'Warning'; // Based on https://github.com/postcss/postcss/blob/master/lib/warning.es6#L74
|
||||
// We don't need `plugin` properties.
|
||||
|
||||
this.message = `${this.name}\n\n`;
|
||||
|
||||
if (typeof line !== 'undefined') {
|
||||
this.message += `(${line}:${column}) `;
|
||||
}
|
||||
|
||||
this.message += `${text}`; // We don't need stack https://github.com/postcss/postcss/blob/master/docs/guidelines/runner.md#31-dont-show-js-stack-for-csssyntaxerror
|
||||
|
||||
this.stack = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = Warning;
|
||||
5
node_modules/css-loader/dist/cjs.js
generated
vendored
Normal file
5
node_modules/css-loader/dist/cjs.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
const loader = require('./index');
|
||||
|
||||
module.exports = loader.default;
|
||||
143
node_modules/css-loader/dist/index.js
generated
vendored
Normal file
143
node_modules/css-loader/dist/index.js
generated
vendored
Normal file
@ -0,0 +1,143 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = loader;
|
||||
|
||||
var _loaderUtils = require("loader-utils");
|
||||
|
||||
var _postcss = _interopRequireDefault(require("postcss"));
|
||||
|
||||
var _package = _interopRequireDefault(require("postcss/package.json"));
|
||||
|
||||
var _schemaUtils = _interopRequireDefault(require("schema-utils"));
|
||||
|
||||
var _semver = require("semver");
|
||||
|
||||
var _CssSyntaxError = _interopRequireDefault(require("./CssSyntaxError"));
|
||||
|
||||
var _Warning = _interopRequireDefault(require("./Warning"));
|
||||
|
||||
var _options = _interopRequireDefault(require("./options.json"));
|
||||
|
||||
var _plugins = require("./plugins");
|
||||
|
||||
var _utils = require("./utils");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
function loader(content, map, meta) {
|
||||
const options = (0, _loaderUtils.getOptions)(this) || {};
|
||||
(0, _schemaUtils.default)(_options.default, options, {
|
||||
name: 'CSS Loader',
|
||||
baseDataPath: 'options'
|
||||
});
|
||||
const callback = this.async();
|
||||
const sourceMap = options.sourceMap || false;
|
||||
const plugins = [];
|
||||
|
||||
if ((0, _utils.shouldUseModulesPlugins)(options.modules, this.resourcePath)) {
|
||||
plugins.push(...(0, _utils.getModulesPlugins)(options, this));
|
||||
}
|
||||
|
||||
const exportType = options.onlyLocals ? 'locals' : 'full';
|
||||
const preRequester = (0, _utils.getPreRequester)(this);
|
||||
|
||||
const urlHandler = url => (0, _loaderUtils.stringifyRequest)(this, preRequester(options.importLoaders) + url);
|
||||
|
||||
plugins.push((0, _plugins.icssParser)({
|
||||
urlHandler
|
||||
}));
|
||||
|
||||
if (options.import !== false && exportType === 'full') {
|
||||
plugins.push((0, _plugins.importParser)({
|
||||
filter: (0, _utils.getFilter)(options.import, this.resourcePath),
|
||||
urlHandler
|
||||
}));
|
||||
}
|
||||
|
||||
if (options.url !== false && exportType === 'full') {
|
||||
plugins.push((0, _plugins.urlParser)({
|
||||
filter: (0, _utils.getFilter)(options.url, this.resourcePath, value => (0, _loaderUtils.isUrlRequest)(value)),
|
||||
urlHandler: url => (0, _loaderUtils.stringifyRequest)(this, url)
|
||||
}));
|
||||
} // Reuse CSS AST (PostCSS AST e.g 'postcss-loader') to avoid reparsing
|
||||
|
||||
|
||||
if (meta) {
|
||||
const {
|
||||
ast
|
||||
} = meta;
|
||||
|
||||
if (ast && ast.type === 'postcss' && (0, _semver.satisfies)(ast.version, `^${_package.default.version}`)) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
content = ast.root;
|
||||
}
|
||||
}
|
||||
|
||||
(0, _postcss.default)(plugins).process(content, {
|
||||
from: this.resourcePath,
|
||||
to: this.resourcePath,
|
||||
map: options.sourceMap ? {
|
||||
// Some loaders (example `"postcss-loader": "1.x.x"`) always generates source map, we should remove it
|
||||
prev: sourceMap && map ? (0, _utils.normalizeSourceMap)(map) : null,
|
||||
inline: false,
|
||||
annotation: false
|
||||
} : false
|
||||
}).then(result => {
|
||||
for (const warning of result.warnings()) {
|
||||
this.emitWarning(new _Warning.default(warning));
|
||||
}
|
||||
|
||||
const imports = [];
|
||||
const apiImports = [];
|
||||
const urlReplacements = [];
|
||||
const icssReplacements = [];
|
||||
const exports = [];
|
||||
|
||||
for (const message of result.messages) {
|
||||
// eslint-disable-next-line default-case
|
||||
switch (message.type) {
|
||||
case 'import':
|
||||
imports.push(message.value);
|
||||
break;
|
||||
|
||||
case 'api-import':
|
||||
apiImports.push(message.value);
|
||||
break;
|
||||
|
||||
case 'url-replacement':
|
||||
urlReplacements.push(message.value);
|
||||
break;
|
||||
|
||||
case 'icss-replacement':
|
||||
icssReplacements.push(message.value);
|
||||
break;
|
||||
|
||||
case 'export':
|
||||
exports.push(message.value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const {
|
||||
localsConvention
|
||||
} = options;
|
||||
const esModule = typeof options.esModule !== 'undefined' ? options.esModule : false;
|
||||
const importCode = (0, _utils.getImportCode)(this, exportType, imports, esModule);
|
||||
const moduleCode = (0, _utils.getModuleCode)(result, exportType, sourceMap, apiImports, urlReplacements, icssReplacements, esModule);
|
||||
const exportCode = (0, _utils.getExportCode)(exports, exportType, localsConvention, icssReplacements, esModule);
|
||||
return callback(null, `${importCode}${moduleCode}${exportCode}`);
|
||||
}).catch(error => {
|
||||
if (error.file) {
|
||||
this.addDependency(error.file);
|
||||
}
|
||||
|
||||
callback(error.name === 'CssSyntaxError' ? new _CssSyntaxError.default(error) : error);
|
||||
});
|
||||
}
|
||||
127
node_modules/css-loader/dist/options.json
generated
vendored
Normal file
127
node_modules/css-loader/dist/options.json
generated
vendored
Normal file
@ -0,0 +1,127 @@
|
||||
{
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"url": {
|
||||
"description": "Enables/Disables 'url'/'image-set' functions handling (https://github.com/webpack-contrib/css-loader#url).",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"instanceof": "Function"
|
||||
}
|
||||
]
|
||||
},
|
||||
"import": {
|
||||
"description": "Enables/Disables '@import' at-rules handling (https://github.com/webpack-contrib/css-loader#import).",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"instanceof": "Function"
|
||||
}
|
||||
]
|
||||
},
|
||||
"modules": {
|
||||
"description": "Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules).",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"enum": ["local", "global", "pure"]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"auto": {
|
||||
"anyOf": [
|
||||
{
|
||||
"instanceof": "RegExp"
|
||||
},
|
||||
{
|
||||
"instanceof": "Function"
|
||||
},
|
||||
{
|
||||
"type": "boolean"
|
||||
}
|
||||
]
|
||||
},
|
||||
"mode": {
|
||||
"anyOf": [
|
||||
{
|
||||
"enum": ["local", "global", "pure"]
|
||||
},
|
||||
{
|
||||
"instanceof": "Function"
|
||||
}
|
||||
]
|
||||
},
|
||||
"exportGlobals": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"localIdentName": {
|
||||
"type": "string"
|
||||
},
|
||||
"localIdentRegExp": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"instanceof": "RegExp"
|
||||
}
|
||||
]
|
||||
},
|
||||
"context": {
|
||||
"type": "string"
|
||||
},
|
||||
"hashPrefix": {
|
||||
"type": "string"
|
||||
},
|
||||
"getLocalIdent": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"instanceof": "Function"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"sourceMap": {
|
||||
"description": "Enables/Disables generation of source maps (https://github.com/webpack-contrib/css-loader#sourcemap).",
|
||||
"type": "boolean"
|
||||
},
|
||||
"importLoaders": {
|
||||
"description": "Enables/Disables or setups number of loaders applied before CSS loader (https://github.com/webpack-contrib/css-loader#importloaders).",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "integer"
|
||||
}
|
||||
]
|
||||
},
|
||||
"localsConvention": {
|
||||
"description": "Style of exported classnames (https://github.com/webpack-contrib/css-loader#localsconvention).",
|
||||
"enum": ["asIs", "camelCase", "camelCaseOnly", "dashes", "dashesOnly"]
|
||||
},
|
||||
"onlyLocals": {
|
||||
"description": "Export only locals (https://github.com/webpack-contrib/css-loader#onlylocals).",
|
||||
"type": "boolean"
|
||||
},
|
||||
"esModule": {
|
||||
"description": "Use the ES modules syntax (https://github.com/webpack-contrib/css-loader#esmodule).",
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
31
node_modules/css-loader/dist/plugins/index.js
generated
vendored
Normal file
31
node_modules/css-loader/dist/plugins/index.js
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "importParser", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _postcssImportParser.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "icssParser", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _postcssIcssParser.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "urlParser", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _postcssUrlParser.default;
|
||||
}
|
||||
});
|
||||
|
||||
var _postcssImportParser = _interopRequireDefault(require("./postcss-import-parser"));
|
||||
|
||||
var _postcssIcssParser = _interopRequireDefault(require("./postcss-icss-parser"));
|
||||
|
||||
var _postcssUrlParser = _interopRequireDefault(require("./postcss-url-parser"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
100
node_modules/css-loader/dist/plugins/postcss-icss-parser.js
generated
vendored
Normal file
100
node_modules/css-loader/dist/plugins/postcss-icss-parser.js
generated
vendored
Normal file
@ -0,0 +1,100 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _postcss = _interopRequireDefault(require("postcss"));
|
||||
|
||||
var _icssUtils = require("icss-utils");
|
||||
|
||||
var _loaderUtils = require("loader-utils");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function makeRequestableIcssImports(icssImports) {
|
||||
return Object.keys(icssImports).reduce((accumulator, url) => {
|
||||
const tokensMap = icssImports[url];
|
||||
const tokens = Object.keys(tokensMap);
|
||||
|
||||
if (tokens.length === 0) {
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
const normalizedUrl = (0, _loaderUtils.urlToRequest)(url);
|
||||
|
||||
if (!accumulator[normalizedUrl]) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
accumulator[normalizedUrl] = tokensMap;
|
||||
} else {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
accumulator[normalizedUrl] = { ...accumulator[normalizedUrl],
|
||||
...tokensMap
|
||||
};
|
||||
}
|
||||
|
||||
return accumulator;
|
||||
}, {});
|
||||
}
|
||||
|
||||
var _default = _postcss.default.plugin('postcss-icss-parser', options => (css, result) => {
|
||||
const importReplacements = Object.create(null);
|
||||
const extractedICSS = (0, _icssUtils.extractICSS)(css);
|
||||
const icssImports = makeRequestableIcssImports(extractedICSS.icssImports);
|
||||
|
||||
for (const [importIndex, url] of Object.keys(icssImports).entries()) {
|
||||
const importName = `___CSS_LOADER_ICSS_IMPORT_${importIndex}___`;
|
||||
result.messages.push({
|
||||
type: 'import',
|
||||
value: {
|
||||
importName,
|
||||
url: options.urlHandler ? options.urlHandler(url) : url
|
||||
}
|
||||
}, {
|
||||
type: 'api-import',
|
||||
value: {
|
||||
type: 'internal',
|
||||
importName,
|
||||
dedupe: true
|
||||
}
|
||||
});
|
||||
const tokenMap = icssImports[url];
|
||||
const tokens = Object.keys(tokenMap);
|
||||
|
||||
for (const [replacementIndex, token] of tokens.entries()) {
|
||||
const replacementName = `___CSS_LOADER_ICSS_IMPORT_${importIndex}_REPLACEMENT_${replacementIndex}___`;
|
||||
const localName = tokenMap[token];
|
||||
importReplacements[token] = replacementName;
|
||||
result.messages.push({
|
||||
type: 'icss-replacement',
|
||||
value: {
|
||||
replacementName,
|
||||
importName,
|
||||
localName
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(importReplacements).length > 0) {
|
||||
(0, _icssUtils.replaceSymbols)(css, importReplacements);
|
||||
}
|
||||
|
||||
const {
|
||||
icssExports
|
||||
} = extractedICSS;
|
||||
|
||||
for (const name of Object.keys(icssExports)) {
|
||||
const value = (0, _icssUtils.replaceValueSymbols)(icssExports[name], importReplacements);
|
||||
result.messages.push({
|
||||
type: 'export',
|
||||
value: {
|
||||
name,
|
||||
value
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
exports.default = _default;
|
||||
141
node_modules/css-loader/dist/plugins/postcss-import-parser.js
generated
vendored
Normal file
141
node_modules/css-loader/dist/plugins/postcss-import-parser.js
generated
vendored
Normal file
@ -0,0 +1,141 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _postcss = _interopRequireDefault(require("postcss"));
|
||||
|
||||
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
||||
|
||||
var _loaderUtils = require("loader-utils");
|
||||
|
||||
var _utils = require("../utils");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const pluginName = 'postcss-import-parser';
|
||||
|
||||
var _default = _postcss.default.plugin(pluginName, options => (css, result) => {
|
||||
const importsMap = new Map();
|
||||
css.walkAtRules(/^import$/i, atRule => {
|
||||
// Convert only top-level @import
|
||||
if (atRule.parent.type !== 'root') {
|
||||
return;
|
||||
} // Nodes do not exists - `@import url('http://') :root {}`
|
||||
|
||||
|
||||
if (atRule.nodes) {
|
||||
result.warn("It looks like you didn't end your @import statement correctly. Child nodes are attached to it.", {
|
||||
node: atRule
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
nodes
|
||||
} = (0, _postcssValueParser.default)(atRule.params); // No nodes - `@import ;`
|
||||
// Invalid type - `@import foo-bar;`
|
||||
|
||||
if (nodes.length === 0 || nodes[0].type !== 'string' && nodes[0].type !== 'function') {
|
||||
result.warn(`Unable to find uri in "${atRule.toString()}"`, {
|
||||
node: atRule
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let isStringValue;
|
||||
let url;
|
||||
|
||||
if (nodes[0].type === 'string') {
|
||||
isStringValue = true;
|
||||
url = nodes[0].value;
|
||||
} else if (nodes[0].type === 'function') {
|
||||
// Invalid function - `@import nourl(test.css);`
|
||||
if (nodes[0].value.toLowerCase() !== 'url') {
|
||||
result.warn(`Unable to find uri in "${atRule.toString()}"`, {
|
||||
node: atRule
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
isStringValue = nodes[0].nodes.length !== 0 && nodes[0].nodes[0].type === 'string';
|
||||
url = isStringValue ? nodes[0].nodes[0].value : _postcssValueParser.default.stringify(nodes[0].nodes);
|
||||
} // Empty url - `@import "";` or `@import url();`
|
||||
|
||||
|
||||
if (url.trim().length === 0) {
|
||||
result.warn(`Unable to find uri in "${atRule.toString()}"`, {
|
||||
node: atRule
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const isRequestable = (0, _loaderUtils.isUrlRequest)(url);
|
||||
|
||||
if (isRequestable) {
|
||||
url = (0, _utils.normalizeUrl)(url, isStringValue); // Empty url after normalize - `@import '\
|
||||
// \
|
||||
// \
|
||||
// ';
|
||||
|
||||
if (url.trim().length === 0) {
|
||||
result.warn(`Unable to find uri in "${atRule.toString()}"`, {
|
||||
node: atRule
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const media = _postcssValueParser.default.stringify(nodes.slice(1)).trim().toLowerCase();
|
||||
|
||||
if (options.filter && !options.filter({
|
||||
url,
|
||||
media
|
||||
})) {
|
||||
return;
|
||||
}
|
||||
|
||||
atRule.remove();
|
||||
|
||||
if (isRequestable) {
|
||||
const importKey = url;
|
||||
let importName = importsMap.get(importKey);
|
||||
|
||||
if (!importName) {
|
||||
importName = `___CSS_LOADER_AT_RULE_IMPORT_${importsMap.size}___`;
|
||||
importsMap.set(importKey, importName);
|
||||
result.messages.push({
|
||||
type: 'import',
|
||||
value: {
|
||||
importName,
|
||||
url: options.urlHandler ? options.urlHandler(url) : url
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
result.messages.push({
|
||||
type: 'api-import',
|
||||
value: {
|
||||
type: 'internal',
|
||||
importName,
|
||||
media
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
result.messages.push({
|
||||
pluginName,
|
||||
type: 'api-import',
|
||||
value: {
|
||||
type: 'external',
|
||||
url,
|
||||
media
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
exports.default = _default;
|
||||
161
node_modules/css-loader/dist/plugins/postcss-url-parser.js
generated
vendored
Normal file
161
node_modules/css-loader/dist/plugins/postcss-url-parser.js
generated
vendored
Normal file
@ -0,0 +1,161 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _postcss = _interopRequireDefault(require("postcss"));
|
||||
|
||||
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
||||
|
||||
var _utils = require("../utils");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const pluginName = 'postcss-url-parser';
|
||||
const isUrlFunc = /url/i;
|
||||
const isImageSetFunc = /^(?:-webkit-)?image-set$/i;
|
||||
const needParseDecl = /(?:url|(?:-webkit-)?image-set)\(/i;
|
||||
|
||||
function getNodeFromUrlFunc(node) {
|
||||
return node.nodes && node.nodes[0];
|
||||
}
|
||||
|
||||
function walkUrls(parsed, callback) {
|
||||
parsed.walk(node => {
|
||||
if (node.type !== 'function') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isUrlFunc.test(node.value)) {
|
||||
const {
|
||||
nodes
|
||||
} = node;
|
||||
const isStringValue = nodes.length !== 0 && nodes[0].type === 'string';
|
||||
const url = isStringValue ? nodes[0].value : _postcssValueParser.default.stringify(nodes);
|
||||
callback(getNodeFromUrlFunc(node), url, false, isStringValue); // Do not traverse inside `url`
|
||||
// eslint-disable-next-line consistent-return
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isImageSetFunc.test(node.value)) {
|
||||
for (const nNode of node.nodes) {
|
||||
const {
|
||||
type,
|
||||
value
|
||||
} = nNode;
|
||||
|
||||
if (type === 'function' && isUrlFunc.test(value)) {
|
||||
const {
|
||||
nodes
|
||||
} = nNode;
|
||||
const isStringValue = nodes.length !== 0 && nodes[0].type === 'string';
|
||||
const url = isStringValue ? nodes[0].value : _postcssValueParser.default.stringify(nodes);
|
||||
callback(getNodeFromUrlFunc(nNode), url, false, isStringValue);
|
||||
}
|
||||
|
||||
if (type === 'string') {
|
||||
callback(nNode, value, true, true);
|
||||
}
|
||||
} // Do not traverse inside `image-set`
|
||||
// eslint-disable-next-line consistent-return
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var _default = _postcss.default.plugin(pluginName, options => (css, result) => {
|
||||
const importsMap = new Map();
|
||||
const replacementsMap = new Map();
|
||||
let hasHelper = false;
|
||||
css.walkDecls(decl => {
|
||||
if (!needParseDecl.test(decl.value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const parsed = (0, _postcssValueParser.default)(decl.value);
|
||||
walkUrls(parsed, (node, url, needQuotes, isStringValue) => {
|
||||
// https://www.w3.org/TR/css-syntax-3/#typedef-url-token
|
||||
if (url.replace(/^[\s]+|[\s]+$/g, '').length === 0) {
|
||||
result.warn(`Unable to find uri in '${decl ? decl.toString() : decl.value}'`, {
|
||||
node: decl
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (options.filter && !options.filter(url)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const splittedUrl = url.split(/(\?)?#/);
|
||||
const [urlWithoutHash, singleQuery, hashValue] = splittedUrl;
|
||||
const hash = singleQuery || hashValue ? `${singleQuery ? '?' : ''}${hashValue ? `#${hashValue}` : ''}` : '';
|
||||
const normalizedUrl = (0, _utils.normalizeUrl)(urlWithoutHash, isStringValue);
|
||||
const importKey = normalizedUrl;
|
||||
let importName = importsMap.get(importKey);
|
||||
|
||||
if (!importName) {
|
||||
importName = `___CSS_LOADER_URL_IMPORT_${importsMap.size}___`;
|
||||
importsMap.set(importKey, importName);
|
||||
|
||||
if (!hasHelper) {
|
||||
const urlToHelper = require.resolve('../runtime/getUrl.js');
|
||||
|
||||
result.messages.push({
|
||||
pluginName,
|
||||
type: 'import',
|
||||
value: {
|
||||
importName: '___CSS_LOADER_GET_URL_IMPORT___',
|
||||
url: options.urlHandler ? options.urlHandler(urlToHelper) : urlToHelper
|
||||
}
|
||||
});
|
||||
hasHelper = true;
|
||||
}
|
||||
|
||||
result.messages.push({
|
||||
pluginName,
|
||||
type: 'import',
|
||||
value: {
|
||||
importName,
|
||||
url: options.urlHandler ? options.urlHandler(normalizedUrl) : normalizedUrl
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const replacementKey = JSON.stringify({
|
||||
importKey,
|
||||
hash,
|
||||
needQuotes
|
||||
});
|
||||
let replacementName = replacementsMap.get(replacementKey);
|
||||
|
||||
if (!replacementName) {
|
||||
replacementName = `___CSS_LOADER_URL_REPLACEMENT_${replacementsMap.size}___`;
|
||||
replacementsMap.set(replacementKey, replacementName);
|
||||
result.messages.push({
|
||||
pluginName,
|
||||
type: 'url-replacement',
|
||||
value: {
|
||||
replacementName,
|
||||
importName,
|
||||
hash,
|
||||
needQuotes
|
||||
}
|
||||
});
|
||||
} // eslint-disable-next-line no-param-reassign
|
||||
|
||||
|
||||
node.type = 'word'; // eslint-disable-next-line no-param-reassign
|
||||
|
||||
node.value = replacementName;
|
||||
}); // eslint-disable-next-line no-param-reassign
|
||||
|
||||
decl.value = parsed.toString();
|
||||
});
|
||||
});
|
||||
|
||||
exports.default = _default;
|
||||
94
node_modules/css-loader/dist/runtime/api.js
generated
vendored
Normal file
94
node_modules/css-loader/dist/runtime/api.js
generated
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
// css base code, injected by the css-loader
|
||||
// eslint-disable-next-line func-names
|
||||
module.exports = function (useSourceMap) {
|
||||
var list = []; // return the list of modules as css string
|
||||
|
||||
list.toString = function toString() {
|
||||
return this.map(function (item) {
|
||||
var content = cssWithMappingToString(item, useSourceMap);
|
||||
|
||||
if (item[2]) {
|
||||
return "@media ".concat(item[2], " {").concat(content, "}");
|
||||
}
|
||||
|
||||
return content;
|
||||
}).join('');
|
||||
}; // import a list of modules into the list
|
||||
// eslint-disable-next-line func-names
|
||||
|
||||
|
||||
list.i = function (modules, mediaQuery, dedupe) {
|
||||
if (typeof modules === 'string') {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
modules = [[null, modules, '']];
|
||||
}
|
||||
|
||||
var alreadyImportedModules = {};
|
||||
|
||||
if (dedupe) {
|
||||
for (var i = 0; i < this.length; i++) {
|
||||
// eslint-disable-next-line prefer-destructuring
|
||||
var id = this[i][0];
|
||||
|
||||
if (id != null) {
|
||||
alreadyImportedModules[id] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var _i = 0; _i < modules.length; _i++) {
|
||||
var item = [].concat(modules[_i]);
|
||||
|
||||
if (dedupe && alreadyImportedModules[item[0]]) {
|
||||
// eslint-disable-next-line no-continue
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mediaQuery) {
|
||||
if (!item[2]) {
|
||||
item[2] = mediaQuery;
|
||||
} else {
|
||||
item[2] = "".concat(mediaQuery, " and ").concat(item[2]);
|
||||
}
|
||||
}
|
||||
|
||||
list.push(item);
|
||||
}
|
||||
};
|
||||
|
||||
return list;
|
||||
};
|
||||
|
||||
function cssWithMappingToString(item, useSourceMap) {
|
||||
var content = item[1] || ''; // eslint-disable-next-line prefer-destructuring
|
||||
|
||||
var cssMapping = item[3];
|
||||
|
||||
if (!cssMapping) {
|
||||
return content;
|
||||
}
|
||||
|
||||
if (useSourceMap && typeof btoa === 'function') {
|
||||
var sourceMapping = toComment(cssMapping);
|
||||
var sourceURLs = cssMapping.sources.map(function (source) {
|
||||
return "/*# sourceURL=".concat(cssMapping.sourceRoot || '').concat(source, " */");
|
||||
});
|
||||
return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
|
||||
}
|
||||
|
||||
return [content].join('\n');
|
||||
} // Adapted from convert-source-map (MIT)
|
||||
|
||||
|
||||
function toComment(sourceMap) {
|
||||
// eslint-disable-next-line no-undef
|
||||
var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
|
||||
var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
|
||||
return "/*# ".concat(data, " */");
|
||||
}
|
||||
34
node_modules/css-loader/dist/runtime/getUrl.js
generated
vendored
Normal file
34
node_modules/css-loader/dist/runtime/getUrl.js
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = function (url, options) {
|
||||
if (!options) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
options = {};
|
||||
} // eslint-disable-next-line no-underscore-dangle, no-param-reassign
|
||||
|
||||
|
||||
url = url && url.__esModule ? url.default : url;
|
||||
|
||||
if (typeof url !== 'string') {
|
||||
return url;
|
||||
} // If url is already wrapped in quotes, remove them
|
||||
|
||||
|
||||
if (/^['"].*['"]$/.test(url)) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
url = url.slice(1, -1);
|
||||
}
|
||||
|
||||
if (options.hash) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
url += options.hash;
|
||||
} // Should url be wrapped?
|
||||
// See https://drafts.csswg.org/css-values-3/#urls
|
||||
|
||||
|
||||
if (/["'() \t\n]/.test(url) || options.needQuotes) {
|
||||
return "\"".concat(url.replace(/"/g, '\\"').replace(/\n/g, '\\n'), "\"");
|
||||
}
|
||||
|
||||
return url;
|
||||
};
|
||||
383
node_modules/css-loader/dist/utils.js
generated
vendored
Normal file
383
node_modules/css-loader/dist/utils.js
generated
vendored
Normal file
@ -0,0 +1,383 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.normalizeUrl = normalizeUrl;
|
||||
exports.getFilter = getFilter;
|
||||
exports.getModulesPlugins = getModulesPlugins;
|
||||
exports.normalizeSourceMap = normalizeSourceMap;
|
||||
exports.getPreRequester = getPreRequester;
|
||||
exports.getImportCode = getImportCode;
|
||||
exports.getModuleCode = getModuleCode;
|
||||
exports.getExportCode = getExportCode;
|
||||
exports.shouldUseModulesPlugins = shouldUseModulesPlugins;
|
||||
|
||||
var _path = _interopRequireDefault(require("path"));
|
||||
|
||||
var _loaderUtils = require("loader-utils");
|
||||
|
||||
var _normalizePath = _interopRequireDefault(require("normalize-path"));
|
||||
|
||||
var _cssesc = _interopRequireDefault(require("cssesc"));
|
||||
|
||||
var _postcssModulesValues = _interopRequireDefault(require("postcss-modules-values"));
|
||||
|
||||
var _postcssModulesLocalByDefault = _interopRequireDefault(require("postcss-modules-local-by-default"));
|
||||
|
||||
var _postcssModulesExtractImports = _interopRequireDefault(require("postcss-modules-extract-imports"));
|
||||
|
||||
var _postcssModulesScope = _interopRequireDefault(require("postcss-modules-scope"));
|
||||
|
||||
var _camelcase = _interopRequireDefault(require("camelcase"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
const whitespace = '[\\x20\\t\\r\\n\\f]';
|
||||
const unescapeRegExp = new RegExp(`\\\\([\\da-f]{1,6}${whitespace}?|(${whitespace})|.)`, 'ig');
|
||||
|
||||
function unescape(str) {
|
||||
return str.replace(unescapeRegExp, (_, escaped, escapedWhitespace) => {
|
||||
const high = `0x${escaped}` - 0x10000;
|
||||
/* eslint-disable line-comment-position */
|
||||
// NaN means non-codepoint
|
||||
// Workaround erroneous numeric interpretation of +"0x"
|
||||
// eslint-disable-next-line no-self-compare
|
||||
|
||||
return high !== high || escapedWhitespace ? escaped : high < 0 ? // BMP codepoint
|
||||
String.fromCharCode(high + 0x10000) : // Supplemental Plane codepoint (surrogate pair)
|
||||
// eslint-disable-next-line no-bitwise
|
||||
String.fromCharCode(high >> 10 | 0xd800, high & 0x3ff | 0xdc00);
|
||||
/* eslint-enable line-comment-position */
|
||||
});
|
||||
} // eslint-disable-next-line no-control-regex
|
||||
|
||||
|
||||
const filenameReservedRegex = /[<>:"/\\|?*\x00-\x1F]/g; // eslint-disable-next-line no-control-regex
|
||||
|
||||
const reControlChars = /[\u0000-\u001f\u0080-\u009f]/g;
|
||||
const reRelativePath = /^\.+/;
|
||||
|
||||
function getLocalIdent(loaderContext, localIdentName, localName, options) {
|
||||
if (!options.context) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
options.context = loaderContext.rootContext;
|
||||
}
|
||||
|
||||
const request = (0, _normalizePath.default)(_path.default.relative(options.context || '', loaderContext.resourcePath)); // eslint-disable-next-line no-param-reassign
|
||||
|
||||
options.content = `${options.hashPrefix + request}+${unescape(localName)}`; // Using `[path]` placeholder outputs `/` we need escape their
|
||||
// Also directories can contains invalid characters for css we need escape their too
|
||||
|
||||
return (0, _cssesc.default)((0, _loaderUtils.interpolateName)(loaderContext, localIdentName, options) // For `[hash]` placeholder
|
||||
.replace(/^((-?[0-9])|--)/, '_$1').replace(filenameReservedRegex, '-').replace(reControlChars, '-').replace(reRelativePath, '-').replace(/\./g, '-'), {
|
||||
isIdentifier: true
|
||||
}).replace(/\\\[local\\\]/gi, localName);
|
||||
}
|
||||
|
||||
function normalizeUrl(url, isStringValue) {
|
||||
let normalizedUrl = url;
|
||||
|
||||
if (isStringValue && /\\[\n]/.test(normalizedUrl)) {
|
||||
normalizedUrl = normalizedUrl.replace(/\\[\n]/g, '');
|
||||
}
|
||||
|
||||
return (0, _loaderUtils.urlToRequest)(decodeURIComponent(unescape(normalizedUrl)));
|
||||
}
|
||||
|
||||
function getFilter(filter, resourcePath, defaultFilter = null) {
|
||||
return item => {
|
||||
if (defaultFilter && !defaultFilter(item)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof filter === 'function') {
|
||||
return filter(item, resourcePath);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
function shouldUseModulesPlugins(modules, resourcePath) {
|
||||
if (typeof modules === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof modules === 'boolean') {
|
||||
return modules;
|
||||
}
|
||||
|
||||
if (typeof modules === 'string') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (typeof modules.auto === 'boolean') {
|
||||
return modules.auto ? /\.module\.\w+$/i.test(resourcePath) : false;
|
||||
}
|
||||
|
||||
if (modules.auto instanceof RegExp) {
|
||||
return modules.auto.test(resourcePath);
|
||||
}
|
||||
|
||||
if (typeof modules.auto === 'function') {
|
||||
return modules.auto(resourcePath);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function getModulesPlugins(options, loaderContext) {
|
||||
let modulesOptions = {
|
||||
mode: 'local',
|
||||
exportGlobals: false,
|
||||
localIdentName: '[hash:base64]',
|
||||
getLocalIdent,
|
||||
hashPrefix: '',
|
||||
localIdentRegExp: null
|
||||
};
|
||||
|
||||
if (typeof options.modules === 'boolean' || typeof options.modules === 'string') {
|
||||
modulesOptions.mode = typeof options.modules === 'string' ? options.modules : 'local';
|
||||
} else {
|
||||
modulesOptions = Object.assign({}, modulesOptions, options.modules);
|
||||
}
|
||||
|
||||
if (typeof modulesOptions.mode === 'function') {
|
||||
modulesOptions.mode = modulesOptions.mode(loaderContext.resourcePath);
|
||||
}
|
||||
|
||||
let plugins = [];
|
||||
|
||||
try {
|
||||
plugins = [_postcssModulesValues.default, (0, _postcssModulesLocalByDefault.default)({
|
||||
mode: modulesOptions.mode
|
||||
}), (0, _postcssModulesExtractImports.default)(), (0, _postcssModulesScope.default)({
|
||||
generateScopedName: function generateScopedName(exportName) {
|
||||
let localIdent = modulesOptions.getLocalIdent(loaderContext, modulesOptions.localIdentName, exportName, {
|
||||
context: modulesOptions.context,
|
||||
hashPrefix: modulesOptions.hashPrefix,
|
||||
regExp: modulesOptions.localIdentRegExp
|
||||
});
|
||||
|
||||
if (!localIdent) {
|
||||
localIdent = getLocalIdent(loaderContext, modulesOptions.localIdentName, exportName, {
|
||||
context: modulesOptions.context,
|
||||
hashPrefix: modulesOptions.hashPrefix,
|
||||
regExp: modulesOptions.localIdentRegExp
|
||||
});
|
||||
}
|
||||
|
||||
return localIdent;
|
||||
},
|
||||
exportGlobals: modulesOptions.exportGlobals
|
||||
})];
|
||||
} catch (error) {
|
||||
loaderContext.emitError(error);
|
||||
}
|
||||
|
||||
return plugins;
|
||||
}
|
||||
|
||||
function normalizeSourceMap(map) {
|
||||
let newMap = map; // Some loader emit source map as string
|
||||
// Strip any JSON XSSI avoidance prefix from the string (as documented in the source maps specification), and then parse the string as JSON.
|
||||
|
||||
if (typeof newMap === 'string') {
|
||||
newMap = JSON.parse(newMap);
|
||||
} // Source maps should use forward slash because it is URLs (https://github.com/mozilla/source-map/issues/91)
|
||||
// We should normalize path because previous loaders like `sass-loader` using backslash when generate source map
|
||||
|
||||
|
||||
if (newMap.file) {
|
||||
newMap.file = (0, _normalizePath.default)(newMap.file);
|
||||
}
|
||||
|
||||
if (newMap.sourceRoot) {
|
||||
newMap.sourceRoot = (0, _normalizePath.default)(newMap.sourceRoot);
|
||||
}
|
||||
|
||||
if (newMap.sources) {
|
||||
newMap.sources = newMap.sources.map(source => (0, _normalizePath.default)(source));
|
||||
}
|
||||
|
||||
return newMap;
|
||||
}
|
||||
|
||||
function getPreRequester({
|
||||
loaders,
|
||||
loaderIndex
|
||||
}) {
|
||||
const cache = Object.create(null);
|
||||
return number => {
|
||||
if (cache[number]) {
|
||||
return cache[number];
|
||||
}
|
||||
|
||||
if (number === false) {
|
||||
cache[number] = '';
|
||||
} else {
|
||||
const loadersRequest = loaders.slice(loaderIndex, loaderIndex + 1 + (typeof number !== 'number' ? 0 : number)).map(x => x.request).join('!');
|
||||
cache[number] = `-!${loadersRequest}!`;
|
||||
}
|
||||
|
||||
return cache[number];
|
||||
};
|
||||
}
|
||||
|
||||
function getImportCode(loaderContext, exportType, imports, esModule) {
|
||||
let code = '';
|
||||
|
||||
if (exportType === 'full') {
|
||||
const apiUrl = (0, _loaderUtils.stringifyRequest)(loaderContext, require.resolve('./runtime/api'));
|
||||
code += esModule ? `import ___CSS_LOADER_API_IMPORT___ from ${apiUrl};\n` : `var ___CSS_LOADER_API_IMPORT___ = require(${apiUrl});\n`;
|
||||
}
|
||||
|
||||
for (const item of imports) {
|
||||
const {
|
||||
importName,
|
||||
url
|
||||
} = item;
|
||||
code += esModule ? `import ${importName} from ${url};\n` : `var ${importName} = require(${url});\n`;
|
||||
}
|
||||
|
||||
return code ? `// Imports\n${code}` : '';
|
||||
}
|
||||
|
||||
function getModuleCode(result, exportType, sourceMap, apiImports, urlReplacements, icssReplacements, esModule) {
|
||||
if (exportType !== 'full') {
|
||||
return '';
|
||||
}
|
||||
|
||||
const {
|
||||
css,
|
||||
map
|
||||
} = result;
|
||||
const sourceMapValue = sourceMap && map ? `,${map}` : '';
|
||||
let code = JSON.stringify(css);
|
||||
let beforeCode = '';
|
||||
beforeCode += esModule ? `var exports = ___CSS_LOADER_API_IMPORT___(${sourceMap});\n` : `exports = ___CSS_LOADER_API_IMPORT___(${sourceMap});\n`;
|
||||
|
||||
for (const item of apiImports) {
|
||||
const {
|
||||
type,
|
||||
media,
|
||||
dedupe
|
||||
} = item;
|
||||
beforeCode += type === 'internal' ? `exports.i(${item.importName}${media ? `, ${JSON.stringify(media)}` : dedupe ? ', ""' : ''}${dedupe ? ', true' : ''});\n` : `exports.push([module.id, ${JSON.stringify(`@import url(${item.url});`)}${media ? `, ${JSON.stringify(media)}` : ''}]);\n`;
|
||||
}
|
||||
|
||||
for (const item of urlReplacements) {
|
||||
const {
|
||||
replacementName,
|
||||
importName,
|
||||
hash,
|
||||
needQuotes
|
||||
} = item;
|
||||
const getUrlOptions = [].concat(hash ? [`hash: ${JSON.stringify(hash)}`] : []).concat(needQuotes ? 'needQuotes: true' : []);
|
||||
const preparedOptions = getUrlOptions.length > 0 ? `, { ${getUrlOptions.join(', ')} }` : '';
|
||||
beforeCode += `var ${replacementName} = ___CSS_LOADER_GET_URL_IMPORT___(${importName}${preparedOptions});\n`;
|
||||
code = code.replace(new RegExp(replacementName, 'g'), () => `" + ${replacementName} + "`);
|
||||
}
|
||||
|
||||
for (const replacement of icssReplacements) {
|
||||
const {
|
||||
replacementName,
|
||||
importName,
|
||||
localName
|
||||
} = replacement;
|
||||
code = code.replace(new RegExp(replacementName, 'g'), () => `" + ${importName}.locals[${JSON.stringify(localName)}] + "`);
|
||||
}
|
||||
|
||||
return `${beforeCode}// Module\nexports.push([module.id, ${code}, ""${sourceMapValue}]);\n`;
|
||||
}
|
||||
|
||||
function dashesCamelCase(str) {
|
||||
return str.replace(/-+(\w)/g, (match, firstLetter) => firstLetter.toUpperCase());
|
||||
}
|
||||
|
||||
function getExportCode(exports, exportType, localsConvention, icssReplacements, esModule) {
|
||||
let code = '';
|
||||
let localsCode = '';
|
||||
|
||||
const addExportToLocalsCode = (name, value) => {
|
||||
if (localsCode) {
|
||||
localsCode += `,\n`;
|
||||
}
|
||||
|
||||
localsCode += `\t${JSON.stringify(name)}: ${JSON.stringify(value)}`;
|
||||
};
|
||||
|
||||
for (const {
|
||||
name,
|
||||
value
|
||||
} of exports) {
|
||||
switch (localsConvention) {
|
||||
case 'camelCase':
|
||||
{
|
||||
addExportToLocalsCode(name, value);
|
||||
const modifiedName = (0, _camelcase.default)(name);
|
||||
|
||||
if (modifiedName !== name) {
|
||||
addExportToLocalsCode(modifiedName, value);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'camelCaseOnly':
|
||||
{
|
||||
addExportToLocalsCode((0, _camelcase.default)(name), value);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'dashes':
|
||||
{
|
||||
addExportToLocalsCode(name, value);
|
||||
const modifiedName = dashesCamelCase(name);
|
||||
|
||||
if (modifiedName !== name) {
|
||||
addExportToLocalsCode(modifiedName, value);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'dashesOnly':
|
||||
{
|
||||
addExportToLocalsCode(dashesCamelCase(name), value);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'asIs':
|
||||
default:
|
||||
addExportToLocalsCode(name, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (const replacement of icssReplacements) {
|
||||
const {
|
||||
replacementName,
|
||||
importName,
|
||||
localName
|
||||
} = replacement;
|
||||
localsCode = localsCode.replace(new RegExp(replacementName, 'g'), () => exportType === 'locals' ? `" + ${importName}[${JSON.stringify(localName)}] + "` : `" + ${importName}.locals[${JSON.stringify(localName)}] + "`);
|
||||
}
|
||||
|
||||
if (exportType === 'locals') {
|
||||
code += `${esModule ? 'export default' : 'module.exports ='} ${localsCode ? `{\n${localsCode}\n}` : '{}'};\n`;
|
||||
} else {
|
||||
if (localsCode) {
|
||||
code += `exports.locals = {\n${localsCode}\n};\n`;
|
||||
}
|
||||
|
||||
code += `${esModule ? 'export default' : 'module.exports ='} exports;\n`;
|
||||
}
|
||||
|
||||
return `// Exports\n${code}`;
|
||||
}
|
||||
Reference in New Issue
Block a user