【问题标题】:webpack / npm setup dynamic component loadingwebpack / npm 设置动态组件加载
【发布时间】: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 会是什么样子?

【问题讨论】:

    标签: node.js npm webpack


    【解决方案1】:

    恐怕无法实现。据我所知,一个包中只有一个 package.json。所有其他依赖项都在 node_modules 目录中。您可以让其他模块开发人员发布他们的包,并且在package.json 文件中,他们可以更改指定入口包文件的main 属性。最后,安装他们的包。

    【讨论】:

    • npm install 在其中一个子文件夹中遇到 package.json 时不会触发?由于 babel 的东西,将 package.json 放在 example-module 目录中破坏了我现有的(工作)设置。但它并没有忽视它。所以应该有可能
    猜你喜欢
    • 2018-09-13
    • 1970-01-01
    • 2021-04-01
    • 2016-01-24
    • 1970-01-01
    • 2015-02-02
    • 1970-01-01
    • 1970-01-01
    • 2017-11-04
    相关资源
    最近更新 更多