Vue Browserify Glob Require Demo
A simple browserify setup appropriate for non-SPAs where you just want to register reusable components.
Backend Integration
- Copy
package.json
and.babelrc
to the root of your project. - Update references to
src
inpackage.json
to where you want to keep your JavaScript (e.g.frontend/javascript
). - Copy the files in
src
to the folder you used in step 2. - Update references to
dist
inpackage.json
to your backend's asset pipeline or public folder (e.g.app/assets/javascripts
orpublic/assets
in Rails) - In your layout file(s), add a
script
tag to the end of yourbody
, pointing to your JavaScript build (e.g./assets/build.js
). - Update the
serve
script inpackage.json
to a command that will run your backend server. After that, you will be able to run browserify and your backend server withnpm run dev
. - Update your deployment script to include
npm run build
before any asset compilation process your backend might use (e.g. beforerake assets:precompile
in Rails). - Profit!
Build Setup
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
For more information see the docs for vueify.