This website requires JavaScript.
en
og

如何配置webpack4打包上传一个高性能vue组件到npm

整体目录

|-- src
  |-- add.vue
  |-- del.vue
  |-- index.js
  |-- index.scss
  |-- VueTreeView.vue
|-- .babelrc
|-- package.json
|-- webpack.config.js
add.vue
<template functional>
  <svg
    :class="data.attrs['icon-class']"
    aria-hidden="true"
    v-on="listeners"
    t="1570597569245"
    class="icon"
    viewBox="0 0 1024 1024"
    version="1.1"
    xmlns="http://www.w3.org/2000/svg"
    p-id="1461"
    width="128"
    height="128"
  >
    <path
      d="M959.7 247.4v528.8c0.7 48.7-18.7 95.5-53.7 129.4-35.8 35.8-78.9 53.7-129.5 53.7H247.9c-50.3 0-93.5-17.9-129.4-53.7-35.1-33.9-54.5-80.7-53.7-129.4V247.4c0-50.3 17.9-93.5 53.7-129.4 33.8-35 80.6-54.5 129.3-53.7h528.9c50.3 0 93.5 17.9 129.4 53.7 35.7 35.8 53.6 79 53.6 129.4z m-81.3 528.8V247.4c0-28-10.1-52-29.8-71.9-18.8-19.4-44.8-30.2-71.8-29.8H247.9c-28 0-51.9 10.1-71.8 29.8-19.4 18.8-30.2 44.8-29.8 71.8v528.8c0 28 9.8 51.9 29.8 71.8 19.8 19.9 43.8 29.8 71.8 29.8h528.9c28 0 51.9-9.8 71.8-29.8 19.9-19.8 29.8-43.8 29.8-71.7z m-81.3-284.7V532c0.5 10.7-7.9 19.8-18.6 20.3H247.9c-10.7 0.4-19.8-7.9-20.2-18.7v-42.2c-0.5-10.7 7.9-19.8 18.6-20.3h530.5c6 0 10.8 1.9 14.5 5.7 3.9 3.9 6 9.2 5.8 14.7z m-264.4 305H492c-10.7 0.5-19.8-7.8-20.2-18.5V247.2c-0.4-10.7 7.9-19.8 18.7-20.2h42.1c10.7-0.4 19.8 7.9 20.2 18.7V776c0 6-1.9 10.9-5.7 14.6-3.7 4-9 6.1-14.4 5.9z"
      p-id="1462"
    />
  </svg>
</template>
del.vue
<template functional>
  <svg
    :class="data.attrs['icon-class']"
    aria-hidden="true"
    v-on="listeners"
    t="1570597522703"
    class="icon"
    viewBox="0 0 1024 1024"
    version="1.1"
    xmlns="http://www.w3.org/2000/svg"
    p-id="1339"
    width="128"
    height="128"
  >
    <path
      d="M960.3 247.8v528.1c0.7 48.6-18.8 95.4-53.8 129.2-35.8 35.8-78.9 53.6-129.5 53.6H247.7c-50.3 0-93.5-17.9-129.5-53.6-35.1-33.8-54.5-80.6-53.8-129.2V247.8c0-50.3 17.9-93.4 53.8-129.2 33.9-35 80.8-54.4 129.5-53.6h529.4c50.4 0 93.6 17.9 129.5 53.6 35.8 35.8 53.7 79 53.7 129.2zM878.9 776V247.9c0-28-10.2-51.9-29.9-71.8-18.8-19.4-44.8-30.1-71.8-29.7H247.7c-28 0-51.9 10.1-71.8 29.8-19.4 18.7-30.3 44.7-29.9 71.7V776c0 27.9 9.9 51.8 29.9 71.7 19.9 19.9 43.8 29.7 71.8 29.7h529.4c28 0 52-9.8 71.9-29.8 19.9-19.8 29.9-43.7 29.9-71.6z m-81.5-284.4v40.5c0.5 10.7-7.9 19.8-18.6 20.3H247.7c-10.8 0.4-19.8-7.9-20.2-18.7v-42.1c-0.5-10.7 7.9-19.8 18.6-20.3h531c6 0 10.9 1.9 14.6 5.7 3.9 3.9 6 9.2 5.7 14.6z"
      p-id="1340"
    />
  </svg>
</template>
index.js

```js import VueTreeView from './VueTreeView'

const install = Vue => { if (install.installed) { retur