Cover

Should You Be Using the Vue CLI?

December 1, 2018
No Comments.

The Vue team has been working hard. Much like Angular, the Vue team has a command-line interface (CLI) to help develop projects with Vue.

If all you’re doing is building a SPA, the CLI can really help simplify setting up a project. But is that all you should be doing with Vue?

In my Vue course and talks, I’ve been advocating that Vue is a good middleground between the philosophies of Angular and vanilla JavaScript. Not every project is a Single Page Application (or multi-page application if you prefer). In this way, I really like how Vue can be scaled up as necessary. In my mind this means that there is a use-case for using Vue without the complexities of a JavaScript build step.

What I mean is that I can start an interactive page as simply as adding vue.js and writing some simple JavaScript:

  // <script src="vue.js"></script>
  var view = new Vue({
    el: "#myDiv",
    data: {
      name: "Shawn"  
    },
    methods: {
      save: function () { alert("don't use alerts"; }
    }
  });

As this scales up to use routing, vuex, and composition, I can add TypeScript or Babel, Webpack or Browserfy, and Linting. But for a simple case, it might not be advantageous to use all that complexity.

But what if you know you’re building something big? You’ve decided that Vue is the right solution for a larger project? What if you wanted to use some Webpack only features (e.g. Single Page Components)? Being able to scaffold the build step complexity would be great, no?

If you haven’t played with the Vue CLI, let me describe it very briefly. The Vue CLI is similar to the Angular CLI in that it hides the complexity of having to know how babel or webpack work. It’s pluggable so you can decide when you start to use TypeScript, Babel, Unit Testing, etc. It also allows you to use the CLI to run builds, watch for build changes or even just serve an HTML file to development.

For my use this means I really only do a couple of things with it. I create new projects with the vue new functionality. And I use the project.json intergration to build my projects.

So to answer my own question, “Should You Be Using the Vue CLI”? It depends. I think the use-case of building up incrementally for smaller-use cases is the right way to do it. But if you’re building a large-scale project, Vue CLI can certainly simplify starting a project and building it.

If you haven’t looked at the CLI yet, take a look:

Vue CLI

If you’ve already bought my Vue Course, I’ll be adding a new CLI chapter in the next couple of weeks for free. Look for the announcement here or through your email!