vue-sfc-library
Packaging Vue.js components for npm
Project structure
package.json
build/
rollup.config.js
src/
wrapper.js
my-component.vue
dist/
package.json
wrapper.js
필요한 컴포넌트를 빌드하기 위해 wrapper.js를 통해 묶어줌 (혹은 필요 로직 구현)
// Vue 컴포넌트 import const components = Component1 Component2 Component3 // Vue.use()에서 실행될 함수 선언 { if installinstalled return installinstalled = true Object} // Vue.use()를 위해 모듈 정의 생성const plugin = install // 브라우저 환경에서 Vue가 있다면 Auto-install 진행let GlobalVue = nullif typeof window !== 'undefined' GlobalVue = windowVue else if typeof global !== 'undefined' GlobalVue = globalVueif GlobalVue GlobalVue // 모듈로 사용하는것을 허용
rollup.config.js
input: 'src/wrapper.js' // entry output: name: 'Vest' // 라이브러리명 exports: 'named' plugins: // ES5로 트랜스파일
Build
npm run build