Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
vue-sfc-rollup
Advanced tools
vue-sfc-rollup is a CLI templating utility that scaffolds a minimal setup for compiling a Vue Single File Component (SFC) - or library of multiple SFCs - into a form ready to share via npm. It doesn't assume any particular flavor of CSS or docs generator, so you can use what you're already used to. It's the fastest way to produce npm-ready vue components!
Install globally
# Install globally (recommended)
npm install -g vue-sfc-rollup
sfc-init
OR use via npx
# For immediate, no-install usage
npx vue-sfc-rollup
Then...
# Fill in prompts
# Navigate to library folder
cd path/to/my-component-or-lib
# Do dev stuff using @vue/cli or other live-refresh coding
# - If single component
vue serve ./src/my-component.vue
# - If library
vue serve ./src/lib-dev.vue
# Run build process
npm run build
# Ready to publish!
The vue-sfc-rollup utility scaffolds 4 files (6 in library mode) for you to kick of your SFC development. These files include a minimal rollup config, a corresponding package.json file with build script and dependencies, a wrapper used by rollup when packaging your SFC, and a sample SFC to kick-start development. In library mode, there is also an 'index' which declares the components exposed as part of your library, and a sample library usage file which can be used to load/test your library during development.
If you wish to integrate this into an existing SFC, please check out the vue-sfc-rollup source. The files generated by this utility are located inside the templates
directory of the repository. Merge the important bits of those file with your existing code, and you'll be good to go.
If you just want to try vue-sfc-rollup, you can run it directly via npx vue-sfc-rollup
.
For repeated use, however, you really should install it globally. To do so, simply open a terminal and execute the following:
npm install -g vue-sfc-rollup
Now, whenever you want to start a new component, you can just type sfc-init
to run the wizard, and it will scaffold a new SFC for you!
Using the vue-sfc-rollup wizard is simple. With vue-sfc-rollup installed globally, enter the following:
sfc-init
# Fill in prompts
The wizard will then prompt you for the following:
After prompting you for this information, the wizard then creates copies of the files found in the templates
directory and performs some variable replacement using the information entered.
vue-sfc-rollup is currently focused on packaging your SFC for distribution via npm. The Vue CLI is excellent for the actual development process of your SFC, and it is recommended you use the official tooling. With v3 of the Vue CLI installed globally, you can truly develop your SFC with zero configuration just by entering the following commands:
# Navigate to library folder
cd path/to/my-component-or-lib
# Do dev stuff using @vue/cli or other live-refresh coding
# - If single component
vue serve ./src/my-component.vue
# - If library
vue serve ./src/lib-dev.vue
This will start up a webpack dev server with hot reloading and all the other awesomeness!
Once your development is done, it's time to package your component to publish to npm. The actual process of publishing to npm is left up to you, but the whole purpose of this project is to compile your SFC/library so that it's packaged and ready to go.
# Navigate to library folder
cd path/to/my-component-or-lib
# Run build process
npm run build
# Rollup does its thing...done!
# Ready to publish!
Running the build script results in 3 compiled files in the dist
directory, one for each of the main
, module
, and unpkg
properties listed in your package.json file. With these files are generated, you're ready to go!
FAQs
Quickly generate redistributable components with Rollup
We found that vue-sfc-rollup 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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.