能否仅为打包在特定入口包中的模块应用特定的加载器?
我的 webpack.config.js
module.exports = {
entry: {
bundle: path.resolve(cwd, 'src', 'index.ts'),
tests =[...glob.sync('**/*.spec.ts')],
polyfills: ['polyfill1', 'polyfill2'],
},
output: {
library: pkg.name,
libraryTarget: 'umd',
filename: '[name].js',
umdNamedDefine: true,
path: path.resolve(cwd, 'build'),
},
resolve: {
extensions: ['.ts', '.tsx', '.js', 'mjs']
},
module: {
rules: [{
test: /\.(t|j)s/, // this loader should only be used for every file that is bundled in entrypoint 'tests'
loader: 'babel-loader',
options: {
...options
}
},
{
test: /\.(t|j)s/, // this loader should only be used for every file that is bundled in entrypoint 'bundle'
loader: 'babel-loader',
options: {
...options
}
}
]
}
}
我希望只针对特定入口包中的文件运行特定加载器,在webpack文档中我没有找到如何查询文件所在的包名称的线索,我只能访问文件的文件名。