Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

vue.js - Is it possible to build a vue application without vue-cli?

Like the titles says for itself. Is it possible to build a vue application with the help of webpack and without the vue cli? If not, why? For my understanding vue-cli uses also webpack to build their files.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Yes, of course.

vue-cli uses webpack under-the-hood, but it abstracts away all the tedious webpack configuration with a sensible default so you can focus on just writing your application.

If you need to alter the way your application is built, for example you want to compress image assets, then unless vue-cli provides a config option for your specific need then you will have to alter the webpack configuration in some way (e.g. adding a new loader or altering the configuration of an existing loader, etc). vue-cli does expose some ways to do this, but you don't have full control over the webpack build from the beginning.

I usually have very specific requirements for how I want my web apps to be built, so I opt for the DIY webpack solution so that I have full control over all aspects of the build.

If you don't want to use vue-cli but still want to use webpack, then at minimum I would suggest the following packages:

  • webpack
  • vue
  • vue-loader for compiling and bundling .vue single file components
  • babel-loader for transpiling JavaScript
  • file-loader for image assets
  • style-loader for injecting styles into the DOM at runtime
  • css-loader for loading modules referenced in CSS files like images and fonts

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...