
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
vue-sfc-library
Advanced tools
Packaging Vue.js components for npm
package.json
build/
rollup.config.js
src/
wrapper.js
my-component.vue
dist/
{
"name": "my-component",
"version": "1.2.3",
"main": "dist/my-component.umd.js",
"module": "dist/my-component.esm.js",
"unpkg": "dist/my-component.min.js",
"browser": {
"./sfc": "src/my-component.vue"
},
"scripts": {
// !! Build path์ ์์ main, module, unpkg์ ๊ฒฝ๋ก๊ฐ ๊ฐ์์ผํจ !!
"build": "npm run build:umd & npm run build:es & npm run build:unpkg",
"build:umd": "rollup --config build/rollup.config.js --format umd --file dist/my-component.umd.js",
"build:es": "rollup --config build/rollup.config.js --format es --file dist/my-component.esm.js",
"build:unpkg": "rollup --config build/rollup.config.js --format iife --file dist/my-component.min.js"
},
"devDependencies": {
"node-sass": "^4.12.0",
"rollup": "^1.15.6",
"rollup-plugin-buble": "^0.19.6",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-vue": "^5.0.0",
"sass-loader": "^7.1.0",
"vue": "^2.6.10",
"vue-template-compiler": "^2.6.10",
...
},
...
}
ํ์ํ ์ปดํฌ๋ํธ๋ฅผ ๋น๋ํ๊ธฐ ์ํด wrapper.js๋ฅผ ํตํด ๋ฌถ์ด์ค (ํน์ ํ์ ๋ก์ง ๊ตฌํ)
// Vue ์ปดํฌ๋ํธ import
import Component1 from './a.vue'
import Component2 from './b.vue'
import Component2 from './c.vue'
const components = {
Component1,
Component2,
Component3
}
// Vue.use()์์ ์คํ๋ ํจ์ ์ ์ธ
export function install(Vue) {
if (install.installed) return
install.installed = true
Object.keys(components).forEach(name => {
Vue.component(name, components[name])
})
}
// Vue.use()๋ฅผ ์ํด ๋ชจ๋ ์ ์ ์์ฑ
const plugin = {
install
}
// ๋ธ๋ผ์ฐ์ ํ๊ฒฝ์์ Vue๊ฐ ์๋ค๋ฉด Auto-install ์งํ
let GlobalVue = null
if (typeof window !== 'undefined') {
GlobalVue = window.Vue
} else if (typeof global !== 'undefined') {
GlobalVue = global.Vue
}
if (GlobalVue) {
GlobalVue.use(plugin)
}
// ๋ชจ๋๋ก ์ฌ์ฉํ๋๊ฒ์ ํ์ฉ
export components
import commonjs from 'rollup-plugin-commonjs' // commonjs
import vue from 'rollup-plugin-vue' // SFC ์ ์ด
import buble from 'rollup-plugin-buble' // ๋ธ๋ผ์ฐ์ ๋ฅผ ์ํด ํธ๋์คํ์ผ, ํด๋ฆฌํ ์ ์ฉ
export default {
input: 'src/wrapper.js', // entry
output: {
name: 'Vest', // ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ช
exports: 'named'
},
plugins: [
commonjs(),
vue({
css: true, // style ํ๊ทธ์ ์คํ์ผ์ js ํ์ผ์ ์ฃผ์
(inline)
compileTemplate: true // ํ
ํ๋ฆฟ์ render ํจ์๋ก ๋ณํ
}),
buble() // ES5๋ก ํธ๋์คํ์ผ
]
}
npm run build
FAQs
Vue.js SFC build example
The npm package vue-sfc-library receives a total of 2 weekly downloads. As such, vue-sfc-library popularity was classified as not popular.
We found that vue-sfc-library demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.ย It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.