A full-featured Webpack setup with hot-reload, lint-on-save, unit testing & css extraction.
This is a project template for vue-cli.
$ npm install -g vue-cli
$ vue init webpack my-project
$ cd my-project
$ npm install
$ npm run dev-
npm run dev: first-in-class development experience.- Webpack +
vue-loaderfor single file Vue components. - State preserving hot-reload
- Lint-on-save with ESLint
- Source maps
- Webpack +
-
npm run build: Production ready build.- JavaScript minified with UglifyJS.
- HTML minified with html-minifier.
- CSS across all components extracted into a single file and minified with cssnano.
- All static assets compiled with version hashes for efficient long-term caching, and a production
index.htmlis auto-generated with proper URLs to these generated assets.
-
npm test: Unit tests run in PhantomJS with Karma + karma-jasmine + karma-webpack.- Supports ES2015 in test files.
- Supports all webpack loaders.
- Easy mock injection.
For detailed explanation on how things work, consult the docs for vue-loader.
You will likely need to do some tuning to suit your own needs:
-
Install additional libraries that you need, e.g.
vue-router,vue-resource,vuex, etc... -
Use your preferred
.eslintrcconfig. -
Add your preferred CSS pre-processor, for example:
npm install less-loader --save-dev
-
Working with an existing backend server:
- In
build/webpack.base.conf.js, adddevServer.proxyfield. See docs for webpack dev server proxy.
- In
-
For unit testing:
-
You can run the tests in multiple real browsers by installing more karma launchers and adjusting the
browsersfield inbuild/karma.conf.js. -
You can also swap out Jasmine for other testing frameworks, e.g. use Mocha with karma-mocha.
-
You can fork this repo to create your own boilerplate, and use it with vue-cli:
vue init username/repo my-project