【发布时间】:2021-02-08 09:30:17
【问题描述】:
我创建了一个这样的模块:
export default () => console.log('hello my_module~!')
webpack.config.js文件中的设置如下:
module.exports = {
// ...
output: {
// ...
library: 'hello',
libraryTarget: 'var'
}
}
而在html文件中,脚本代码为:
<script src="/output_my_module.js"></script>
<script>
hello.default(); // yea~ It's work!!
</script>
但我想要的方式如下:
hello(); // I want use like this.
我该怎么办?我读了webpack's doc,但找不到方法。 (可能是因为我英文不好所以错过了……)
【问题讨论】:
标签: javascript node.js npm webpack