We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
默认情况下, 配置的值是依赖库暴露到全局的变量名, 这种情况下需要依赖将自己向 window 上赋值
module.exports = { //... externals: { 'element-ui': 'ELEMENT', // 找 window.ELEMENT }, };
如果 output.libTarget 配置为 'umd', 则配置的值可以是依赖包的包名. 但是这种配置方式的话, 相当于代码不是一个 vue app, 导致本地 vue-cli-service serve 无法启动
vue-cli-service serve
module.exports = { //... externals: { 'element-ui': 'element-ui', }, };
所以如果本地想作为 vue app 开发, 打包的时候想打成 lib, 有两个方法:
const getArgv = (argName) => { const findIndex = process.argv.findIndex((v) => v === argName) return (findIndex === -1) ? '' : process.argv[findIndex + 1] || '' } //... configureWebpack(config) { if (getArgv('--target')=== 'lib') { config.externals = { 'element-ui': 'element-ui', } } },
webpack 关于 externals 的文档
The text was updated successfully, but these errors were encountered:
No branches or pull requests
默认情况下, 配置的值是依赖库暴露到全局的变量名, 这种情况下需要依赖将自己向 window 上赋值
如果 output.libTarget 配置为 'umd', 则配置的值可以是依赖包的包名. 但是这种配置方式的话, 相当于代码不是一个 vue app, 导致本地
vue-cli-service serve
无法启动所以如果本地想作为 vue app 开发, 打包的时候想打成 lib, 有两个方法:
参考
webpack 关于 externals 的文档
The text was updated successfully, but these errors were encountered: