vue-cli 构建库

记录一下,方便自己看。

  1. webpack.json
{
  "name": "vue-mobile-notification",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build --target lib --name test./src/lib/index.js"   **//配置打包入口文件**
    "lint": "vue-cli-service lint"
  },
  "main": "dist/test.umd.js",   **//npm包入口**
  "dependencies": {
    "vue": "^2.5.17",
    "vue-router": "^3.0.1",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^3.2.0",
    "@vue/cli-plugin-eslint": "^3.2.0",
    "@vue/cli-service": "^3.2.0",
    "@vue/eslint-config-standard": "^4.0.0",
    "babel-eslint": "^10.0.1",
    "eslint": "^5.8.0",
    "eslint-plugin-vue": "^5.0.0-0",
    "less": "^3.0.4",
    "less-loader": "^4.1.0",
    "vue-template-compiler": "^2.5.17"
  }
}

2.本地测试 main.js

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import test from './lib/index.js'   **//引入**
Vue.use(test)                              **//引入**

console.log(1111)

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

3.项目目录
src/lib/index.js
src/lib/test.vue

4.index.js vue组件构建

import myNotification from './my-notification.vue'

const test= {}
test.install = function (Vue) {
  Vue.component(mytest.name, mytest)
}
export default test

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值