Webpack 在运行时在Web包中加载json文件
我是Webpack的新手,我的要求是在运行时包含任何JSON文件,而不是使用Webpack绑定的文件 情景: --我必须在webpack.config.js中编写如下代码: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
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); ///
}
);
我需要使用外部或其他插件使用网页包的解决方案。我需要使用外部或其他插件使用网页包的解决方案。