【发布时间】:2018-10-16 14:22:23
【问题描述】:
我有一个包含框架和一些模块的单页应用程序项目。文件设置如下:
_.babelrc
_package.json
_package-lock.json
_webpack.config.js
_node_modules
_src
|_index.js
|_index.html
|_config.json
|_modules
|_example-module
|_index.js
在 src/index.js 中,我将 config.json 中指定的所有模块加载到 index.html 的指定区域中。这运行顺利,但有两点我确实想要改进:
- 所有模块的主句柄必须始终是 index.js。我想重定向它,以便其他模块开发人员可以使用他们想要的任何名称。
- 我想分别指定模块的依赖关系,即为每个模块使用 package.json/webpack.config。这样,人们就不必在主 package.json 中指定他们的包。
这可以使用 npm/webpack 实现吗?如果是这样,框架和各个包的 package.json/webpack.config.js 会是什么样子?
【问题讨论】: