You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
4.3 KiB
123 lines
4.3 KiB
"use strict";
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.StyleRegex = exports.LoaderName = exports.StylingType = void 0;
|
|
const tooltip_1 = __importDefault(require("./tooltip"));
|
|
var StylingType;
|
|
(function (StylingType) {
|
|
StylingType["CSS"] = "CSS";
|
|
StylingType["SASS"] = "SASS";
|
|
StylingType["LESS"] = "LESS";
|
|
StylingType["PostCSS"] = "PostCSS";
|
|
})(StylingType = exports.StylingType || (exports.StylingType = {}));
|
|
var LoaderName;
|
|
(function (LoaderName) {
|
|
LoaderName["CSS"] = "css-loader";
|
|
LoaderName["SASS"] = "sass-loader";
|
|
LoaderName["STYLE"] = "style-loader";
|
|
LoaderName["LESS"] = "less-loader";
|
|
LoaderName["POSTCSS"] = "postcss-loader";
|
|
})(LoaderName = exports.LoaderName || (exports.LoaderName = {}));
|
|
var StyleRegex;
|
|
(function (StyleRegex) {
|
|
StyleRegex["CSS"] = "/.css$/";
|
|
StyleRegex["SASS"] = "/.(sa|sc|c)ss$/";
|
|
StyleRegex["LESS"] = "/.(less|css)$/";
|
|
StyleRegex["PostCSS"] = "/.css$/";
|
|
})(StyleRegex = exports.StyleRegex || (exports.StyleRegex = {}));
|
|
function style(self, stylingType) {
|
|
const ExtractUseProps = [];
|
|
let regExpForStyles = null;
|
|
switch (stylingType) {
|
|
case StylingType.CSS:
|
|
regExpForStyles = StyleRegex.CSS;
|
|
self.dependencies.push(LoaderName.CSS);
|
|
if (!self.isProd) {
|
|
self.dependencies.push(LoaderName.STYLE);
|
|
ExtractUseProps.push({
|
|
loader: `"${LoaderName.STYLE}"`,
|
|
});
|
|
}
|
|
ExtractUseProps.push({
|
|
loader: `"${LoaderName.CSS}"`,
|
|
options: {
|
|
sourceMap: true,
|
|
},
|
|
});
|
|
break;
|
|
case StylingType.SASS:
|
|
regExpForStyles = StyleRegex.SASS;
|
|
self.dependencies.push('node-sass', LoaderName.SASS, LoaderName.CSS);
|
|
if (!self.isProd) {
|
|
self.dependencies.push(LoaderName.STYLE);
|
|
ExtractUseProps.push({
|
|
loader: `"${LoaderName.STYLE}"`,
|
|
});
|
|
}
|
|
ExtractUseProps.push({
|
|
loader: `"${LoaderName.CSS}"`,
|
|
options: {
|
|
sourceMap: true,
|
|
},
|
|
}, {
|
|
loader: `"${LoaderName.SASS}"`,
|
|
options: {
|
|
sourceMap: true,
|
|
},
|
|
});
|
|
break;
|
|
case StylingType.LESS:
|
|
regExpForStyles = StyleRegex.LESS;
|
|
self.dependencies.push('less', LoaderName.LESS, LoaderName.CSS);
|
|
if (!self.isProd) {
|
|
self.dependencies.push(LoaderName.STYLE);
|
|
ExtractUseProps.push({
|
|
loader: `"${LoaderName.STYLE}"`,
|
|
});
|
|
}
|
|
ExtractUseProps.push({
|
|
loader: `"${LoaderName.CSS}"`,
|
|
options: {
|
|
sourceMap: true,
|
|
},
|
|
}, {
|
|
loader: `"${LoaderName.LESS}"`,
|
|
options: {
|
|
sourceMap: true,
|
|
},
|
|
});
|
|
break;
|
|
case StylingType.PostCSS:
|
|
regExpForStyles = StyleRegex.PostCSS;
|
|
self.configuration.config.topScope.push(tooltip_1.default.postcss(), "const autoprefixer = require('autoprefixer');", "const precss = require('precss');", '\n');
|
|
self.dependencies.push('precss', 'autoprefixer', LoaderName.CSS, LoaderName.POSTCSS);
|
|
if (!self.isProd) {
|
|
self.dependencies.push(LoaderName.STYLE);
|
|
ExtractUseProps.push({
|
|
loader: `"${LoaderName.STYLE}"`,
|
|
});
|
|
}
|
|
ExtractUseProps.push({
|
|
loader: `"${LoaderName.CSS}"`,
|
|
options: {
|
|
importLoaders: 1,
|
|
sourceMap: true,
|
|
},
|
|
}, {
|
|
loader: `"${LoaderName.POSTCSS}"`,
|
|
options: {
|
|
plugins: `function () {
|
|
return [
|
|
precss,
|
|
autoprefixer
|
|
];
|
|
}`,
|
|
},
|
|
});
|
|
break;
|
|
}
|
|
return { ExtractUseProps, regExpForStyles };
|
|
}
|
|
exports.default = style;
|
|
|