@sanpjs/bundler-webpack
Version:
@sanpjs/bundler-webpack
39 lines • 1.42 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.script = void 0;
const path_1 = __importDefault(require("path"));
const utils_1 = require("../utils");
const script = (context) => {
if (context.dev && context.config.build.esbuild) {
return {
test: /\.(j|t)s$/,
exclude: [(filepath) => !filepath],
use: [(0, utils_1.getLoader)('esbuild', context)]
};
}
return {
test: /\.(j|t)sx?$/,
exclude: [(filepath) => {
// 兼容webpack 5下data URI,filepath不存在的问题
if (!filepath) {
return true;
}
// 包含 .san 的路径
if (/\.san$/.test(filepath)) {
return false;
}
// 单独排除 sanp 路径
if (filepath.startsWith(path_1.default.join(__dirname, 'node_modules'))) {
return true;
}
// 默认不编译 node_modules,如果要编译使用排除
return /node_modules/.test(filepath);
}],
use: [(0, utils_1.getLoader)('babel', context)]
};
};
exports.script = script;
//# sourceMappingURL=script.js.map