123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _os = _interopRequireDefault(require("os"));
- var _path = _interopRequireDefault(require("path"));
- var _cloneDeep = _interopRequireDefault(require("clone-deep"));
- var _proxyCustomImporters = _interopRequireDefault(require("./proxyCustomImporters"));
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function isProductionLikeMode(loaderContext) {
- return loaderContext.mode === 'production' || !loaderContext.mode || loaderContext.minimize;
- }
- function getSassOptions(loaderContext, loaderOptions, content, implementation) {
- const options = (0, _cloneDeep.default)(loaderOptions.sassOptions ? typeof loaderOptions.sassOptions === 'function' ? loaderOptions.sassOptions(loaderContext) || {} : loaderOptions.sassOptions : {});
- const isDartSass = implementation.info.includes('dart-sass');
- if (isDartSass) {
- const shouldTryToResolveFibers = !options.fiber && options.fiber !== false;
- if (shouldTryToResolveFibers) {
- let fibers;
- try {
- fibers = require.resolve('fibers');
- } catch (_error) {
- }
- if (fibers) {
-
- options.fiber = require(fibers);
- }
- } else if (options.fiber === false) {
-
- delete options.fiber;
- }
- } else {
-
- delete options.fiber;
- }
- options.data = loaderOptions.prependData ? typeof loaderOptions.prependData === 'function' ? loaderOptions.prependData(loaderContext) + _os.default.EOL + content : loaderOptions.prependData + _os.default.EOL + content : content;
- if (!options.outputStyle && isProductionLikeMode(loaderContext)) {
- options.outputStyle = 'compressed';
- }
- const useSourceMap = typeof loaderOptions.sourceMap === 'boolean' ? loaderOptions.sourceMap : loaderContext.sourceMap;
-
-
- if (useSourceMap) {
-
-
-
-
-
-
- options.sourceMap = _path.default.join(process.cwd(), '/sass.map');
- if ('sourceMapRoot' in options === false) {
- options.sourceMapRoot = process.cwd();
- }
- if ('omitSourceMapUrl' in options === false) {
-
-
- options.omitSourceMapUrl = true;
- }
- if ('sourceMapContents' in options === false) {
-
-
- options.sourceMapContents = true;
- }
- }
- const {
- resourcePath
- } = loaderContext;
- const ext = _path.default.extname(resourcePath);
- if (ext && ext.toLowerCase() === '.sass' && 'indentedSyntax' in options === false) {
- options.indentedSyntax = true;
- } else {
- options.indentedSyntax = Boolean(options.indentedSyntax);
- }
- options.importer = options.importer ? (0, _proxyCustomImporters.default)(options.importer, resourcePath) : [];
- options.includePaths = (options.includePaths || []).concat(_path.default.dirname(resourcePath));
- return options;
- }
- var _default = getSassOptions;
- exports.default = _default;
|