# Vue SFC Compiler
> Template for build setup to compile Single File Components (.vue) into a standalone JS file for use in the browser
This template is useful for compiling VueJS single file components (SFC) into standalone JS files for use in the browser. This is useful for devs that want to create a simple component that can be used on a site without having to build an entire app around it, similar to the way a JQuery plugin might be used. The template, script, and styles are all compiled to a single JS file.
The compiler is setup to allow you to use either LESS or SASS (scss or sass) if you want to
As well as pug and **typescript** !
## Usage
This is a project template for [vue-cli](https://github.com/vuejs/vue-cli).
### 1. Create a new Vue project
At the command line, enter the following commands in parent folder of where you will be keeping your project.
``` bash
# Install vue-cli if you haven't already
$ npm install -g vue-cli
# Create a new project based on this template
$ vue init sheychen/vue-sfc-compiler my-project
# Navigate into your new project folder
$ cd my-project
# Install dependencies
$ npm install
```
### 2. Create and compile a component
Create a `.vue` file anywhere in the `src` folder of the project you just created.
Then, run the webpack compiler and point the `--env.file` argument to the .vue file you created (you don't need to add the extension). The path should be relative to the `src` folder, so if you created your `.vue` file in the `src` folder, the path would just be the name of the file. For example, if the file is located in `src/sub-folder/my-component.vue`, the path you would enter for the `--env.file` argument would be `sub-folder/my-component`.
``` bash
$ npm run build path/to/my-component.vue
```
``` bash
$ npm run watch path/to/my-component.vue
```
The webpack compiler runs in watch mode so any changes you make will update the compiled file. Whenever you make changes to you component, as long as the webpack compiler is running, the changes will be re-compiled and saved over the same output file. The compiled output file will be created at the same relative path in the `dist` folder that it was located in the `src` folder. So if you create a component at `src/some-sub-folder/my-rad-component.vue`, the compiled file will be located in `dist/some-sub-folder/my-rad-component.js`.
Once you've completed the development of your component and want to use it, you can take the compiled `.js` file and place it wherever you want.
Make sure you add a `name` property to the script section of the component. This is what will be used as the tag for your component when you use it in your app/HTML file.
Giving your component a name property of `my-component` means you will add your component to the app as `