javascript - 如何高效配置 Webpack?
问题描述
我有一个 React 项目,我们在其中制作 webpack 以从本地和云系统运行它但是这里有一个小的解决方法,我们每次在云中运行它时都需要做。
const devWebpackConfig = {
entry: {
/**
* Add or remove the libraries which goes into vendor bundle file
*/
vendor: ['react', 'react-dom', 'react-router-dom'],
},
devServer: {
// Comment the below line to run from cloud.
host: 'localhost',
// Comment the below line to run from local.
//disableHostCheck: true,
// How do we make sure we need not comment and uncomment this code everytime we run it from cloud systems
port: 8181
},
plugins: [
]
}
我们如何确保每次从云系统运行此代码时都不需要注释和取消注释,这是否可以由 webpack 自动拾取,具体取决于我们使用的环境,如本地或云机器。