lightningcss-loader
Version:
Speed up your Webpack build with lightningcss
26 lines (25 loc) • 950 B
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTargets = exports.isWebpack5 = void 0;
const browserslist_1 = __importDefault(require("browserslist"));
const lightningcss_1 = require("lightningcss");
const isWebpack5 = (compilation) => 'processAssets' in compilation.hooks;
exports.isWebpack5 = isWebpack5;
let targetsCache = {};
const getTargets = (opts) => {
const cache = targetsCache[opts.key];
if (cache) {
return cache;
}
const cwd = process.cwd();
const result = (0, browserslist_1.default)(opts.default, {
path: cwd,
env: process.env.NODE_ENV || 'production',
});
targetsCache[opts.key] = (0, lightningcss_1.browserslistToTargets)(result);
return targetsCache[opts.key];
};
exports.getTargets = getTargets;
;