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
适用于Vue组件库的包括
首先先创建一个空的Vue项目,执行指令:vue create [项目名称]
vue create [项目名称]
将默认的组件与不需要的文件夹删掉,创建一个专门用于存放组件的文件夹,将组件移入文件夹中(组件中使用的字体图标等资源也需要移入该文件夹中)。
创建在根目录创建vue.config.js文件,并配置以下信息:
vue.config.js
const path = require("path"); module.exports = { pages: { index: { // 修改项目的入口文件 entry: "examples/main.js", template: "public/index.html", filename: "index.html", }, }, // 拓展webpack配置,使 components 加入编译(component为举例组件文件夹) chainWebpack: (config) => { config.module .rule("js") .include.add(path.resolve(__dirname, "components")) .end() .use("babel") .loader("babel-loader") .tap((options) => { // 修改它的选项 return options; }); }, };
如果不想将包上传至npm可以跳过此步骤
package.json
name
private
false
main
.npmignore
Vue打包指令:vue-cli-service build --target lib [入口路径]
vue-cli-service build --target lib [入口路径]
登录:npm login
npm login
发布:npm publish
npm publish
PS:发布前需保证源为npm本源
The text was updated successfully, but these errors were encountered:
No branches or pull requests
组件库打包与发布
适用于Vue组件库的包括
创建空的项目
首先先创建一个空的Vue项目,执行指令:
vue create [项目名称]
创建组件所在文件夹
将默认的组件与不需要的文件夹删掉,创建一个专门用于存放组件的文件夹,将组件移入文件夹中(组件中使用的字体图标等资源也需要移入该文件夹中)。
配置Vue
创建在根目录创建
vue.config.js
文件,并配置以下信息:打包前的准备
如果不想将包上传至npm可以跳过此步骤
package.json
name
在npm中唯一private
修改为false
main
,值为入口文件路径.npmignore
文件来过滤上传文件打包组件库
Vue打包指令:
vue-cli-service build --target lib [入口路径]
发布到npm
登录:
npm login
发布:
npm publish
PS:发布前需保证源为npm本源
The text was updated successfully, but these errors were encountered: