Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Webpack 在运行时在Web包中加载json文件_Webpack_External - Fatal编程技术网

Webpack 在运行时在Web包中加载json文件

Webpack 在运行时在Web包中加载json文件,webpack,external,Webpack,External,我是Webpack的新手,我的要求是在运行时包含任何JSON文件,而不是使用Webpack绑定的文件 情景: --我必须在webpack.config.js中编写如下代码: externals: { Conf: JSON.stringify(require('./env/env-dev.json')) } 在另一个组件文件中,我们要求如下:-- 但在这段代码中,当我们在任何组件模块下需要'Conf'时,env-dev.json已加载到捆绑文件中 但当我们在任何组件中都不需要它时,这个e

我是Webpack的新手,我的要求是在运行时包含任何JSON文件,而不是使用Webpack绑定的文件

情景: --我必须在webpack.config.js中编写如下代码:

externals: {
    Conf: JSON.stringify(require('./env/env-dev.json'))
}
在另一个组件文件中,我们要求如下:--

但在这段代码中,当我们在任何组件模块下需要'Conf'时,env-dev.json已加载到捆绑文件中

但当我们在任何组件中都不需要它时,这个env-dev.json将不会加载到捆绑文件中

但我的要求是不想将此文件包含在捆绑文件下。并在任何代码中使用它


请帮帮我。

从文件中读取JSON的示例jQuery函数:

var conf;
$.getJSON( 
      jsonFilePathOrURL,
      function(result, status, xhr) {
                conf = result;
             //..here conf is a JSON variable.....................///
             //...you can get string using JSON.stringify(conf); ///
      }
 );

从文件中读取JSON的示例jQuery函数:

var conf;
$.getJSON( 
      jsonFilePathOrURL,
      function(result, status, xhr) {
                conf = result;
             //..here conf is a JSON variable.....................///
             //...you can get string using JSON.stringify(conf); ///
      }
 );

我需要使用外部或其他插件使用网页包的解决方案。我需要使用外部或其他插件使用网页包的解决方案。