//file config.js ,该loader忽略*.ts里的内容
export default {
plugins,
hash: true,
targets: {
ie: 11,
},
urlLoaderExcludes: [/\.ts$/],
chainWebpack(config) {
config.module.rule('ignore-ts-file')
.test(/\.ts$/)
.use(require.resolve('../loaders/ignore-loader'))
.loader(require.resolve('../loaders/ignore-loader'))
},
...
//file :loaders/ignore-loader
module.exports = function(content) {
//this.cacheable && this.cacheable();
console.log("statring ignore loader")
return '';
}
博客展示了Webpack配置文件config.js,通过设置urlLoaderExcludes忽略*.ts文件内容,还在chainWebpack中配置规则,使用自定义的ignore-loader处理*.ts文件。同时给出了ignore-loader代码,其返回空内容以实现忽略。
9554

被折叠的 条评论
为什么被折叠?



