ko
Version:
build & lint library
76 lines (75 loc) • 2.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../../../utils");
class BabelLoader {
constructor(opts) {
this.BABEL_LOADER = (0, utils_1.getResolvePath)('babel-loader');
this.opts = opts;
}
get config() {
return {
loader: this.BABEL_LOADER,
options: {
presets: [
[
(0, utils_1.getResolvePath)('babel-preset-ko-app'),
{
useAbsoluteRuntime: true,
},
],
],
plugins: this.plugins,
babelrc: false,
configFile: false,
cacheIdentifier: this.cacheIdentifier,
cacheDirectory: !this.speedUp,
cacheCompression: false,
compact: this.opts.isProd,
},
};
}
get treasurePluginConfig() {
const babelPluginTreasurePath = (0, utils_1.getResolvePath)('babel-plugin-treasure');
return [
[
babelPluginTreasurePath,
{
libraryName: 'antd',
libraryDirectory: 'lib',
style: 'css',
},
'antd',
],
[
babelPluginTreasurePath,
{
libraryName: 'dt-react-component',
libraryDirectory: '/src/components/',
camel2DashComponentName: 'lower',
},
'drc',
],
//TODO: check lodash tree shaking in webpack 5
// [
// babelPluginTreasurePath,
// {
// libraryName: 'lodash',
// libraryDirectory: '/',
// camel2DashComponentName: false,
// },
// 'lodash',
// ],
];
}
get plugins() {
return [...this.treasurePluginConfig].filter(Boolean);
}
get cacheIdentifier() {
return (0, utils_1.getCacheIdentifier)(this.opts.isProd ? 'production' : '', [
'ko',
'babel-preset-ko-app',
'babel-plugin-treasure',
]);
}
}
exports.default = BabelLoader;