是否可以在没有vue-cli的情况下构建vue应用程序? [英] Is it possible to build a vue application without vue-cli?
问题描述
就像标题一样。是否可以借助webpack并在没有vue cli的情况下构建vue应用程序?
如果没有,为什么?据我了解,vue-cli也使用webpack来构建其文件。
是的。
vue-cli
在后台使用webpack,但是它通过合理的默认值抽象了所有繁琐的webpack配置,因此您可以集中精力
如果您需要更改应用程序的构建方式,例如要压缩图像资产,则除非 vue-cli
为您的特定需求提供了一个配置选项,然后您将不得不以某种方式更改webpack的配置(例如,添加新的加载器或更改现有加载器的配置等)。 vue-cli
确实提供了一些方法,但是您从一开始就无法完全控制webpack的构建。
我通常对构建Web应用程序有非常具体的要求,因此我选择了DIY Webpack解决方案,以便可以完全控制构建的各个方面。
如果您不想使用 vue-cli
但仍想使用webpack,那么我至少建议使用以下软件包: / p>
-
webpack
-
vue
-
vue-loader
用于编译和捆绑.vue
单个文件组件 -
babel-loader
用于转译JavaScript -
文件加载器
用于图像资产 -
style-loader
用于将样式注入运行时的DOM -
css-loader
用于加载CSS文件中引用的模块(例如图像和字体)
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.
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 componentsbabel-loader
for transpiling JavaScriptfile-loader
for image assetsstyle-loader
for injecting styles into the DOM at runtimecss-loader
for loading modules referenced in CSS files like images and fonts
这篇关于是否可以在没有vue-cli的情况下构建vue应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!