rollupOptions: { external:["vue"] } 是什么意思
时间: 2023-06-07 07:07:35 浏览: 85
这是关于 Rollup 打包工具的配置选项,其中 external:["vue"] 表示在打包过程中将 Vue 库排除在外,而不直接将其打包进最终生成的代码中,以便于在使用时直接从外部引入 Vue 库,从而减小最终文件的大小。
相关问题
rollupOptions: { external: ['vue'], output: { globals: { vue: 'vue', }, }, }, 是什么意思
### 回答1:
这是一个 JavaScript 包的 Rollup 配置选项,用于将依赖的 Vue 库从构建中排除。external 属性告诉 Rollup 哪些模块应该被视为外部模块,这些模块将不会被打包进输出文件中。output 属性中的 globals 对象定义了对应的外部模块的全局变量名称。这对于构建可重用的 JavaScript 库特别有用。
### 回答2:
rollupOptions是用于配置rollup打包工具的选项,其中包含了external和output两个子选项。
external选项用来指定哪些模块是外部模块,即不会被打包进最终的输出文件中。在这里,external: ['vue']表示vue模块被视为外部模块,不会被打包进最终的输出文件中。
output选项用来配置输出文件的设置。其中的globals选项用于指定外部模块的全局变量名。在这里,globals: { vue: 'vue' }表示将外部模块vue指定为全局变量vue。
综合起来,这段配置的意思是,使用rollup打包工具打包时,将vue模块视为外部模块,不会被打包进最终的输出文件中,并且将外部模块vue指定为全局变量vue。
build: { rollupOptions: { external: ['/ant-design-vue'], },
在这段代码中,rollupOptions 是用于配置 Rollup 打包工具的选项,external 是其中的一个选项,用于指定哪些模块应该被视为外部模块,不需要被打包进最终的构建文件中。
在这个例子中,'/ant-design-vue' 被指定为外部模块,意味着 Rollup 不会将它打包进最终的构建文件中。这通常是因为该模块已经被其他方式引入或者是由浏览器运行时加载,不需要被打包进构建文件中。
需要注意的是,如果你想在代码中使用 '/ant-design-vue' 模块,你需要确保在代码执行前已经正确加载了该模块。如果没有加载该模块或者加载不正确,代码将会抛出错误。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)