如何从Webpack中排除模块,而使用es6导入 [英] How to exclude a module from webpack, and instead import it using es6
本文介绍了如何从Webpack中排除模块,而使用es6导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在使用Webpack来打包带有react的javascript文件.此文件还向我项目中的另一个模块提供了另一个导入语句
I am currently using webpack to bundle up a javascript file with react. This file also has another import statement to another module within my project
import { MyModule} from './MyModuleFile.js'
import { MyModule} from './MyModuleFile.js'
是否有办法从Webpack捆绑包中排除MyModule.js,而是将导入保持原样?
Is there a way to exclude MyModule.js from the webpack bundle, and instead keep the import as is?
推荐答案
您追求的是webpack.config.js
module.exports = {
//...
externals: {
'./MyModuleFile': 'MyModule',
}
};
这篇关于如何从Webpack中排除模块,而使用es6导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文