Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vue files without NodeJS?

Tags:

node.js

vue.js

I want to host my app outside of node JS, but I want to use .vue files and possible npm as build system (if it's needed). Is it's possible to do?

I do not need any backward compatibility and if it work on latest Chrome dev it's ok for me.

Is there any examples how it can be done?

I tried to build some webpack template, but it's work only inside NodeJS. On other server I am getting 404 when I am accessing to URLs that placed in .vue files. It's seems that they can't be handled by the other server.

like image 985
Dmitry Bubnenkov Avatar asked Feb 27 '17 11:02

Dmitry Bubnenkov


People also ask

Can I use VueJS without node?

Vue is the front-end framework, node's server language. The two can be used in combination. But not vue must rely on node to use. The two of them can be perfect to achieve the front and back separation of the development model.

Can I use Vue without npm?

It is possible to create Vue. js application using only inline JavaScript and HTML wihout bundling. It's easy to setup and blazingly fast to develop, very useful for small projects.

Can I use Vue without Webpack?

The answer is no. Thanks to native browser support for JavaScript Modules, it's easier than ever to build powerful JavaScript applications without using any build tools. This article discusses ways to build Vue. js applications without relying on a complicated build process and numerous third-party dependencies.

Does Vue need a server?

But Vue doesn't use any server-side language! It's - after your ran npm run build - just a bunch of JavaScript and CSS files as well as the index. html file. You don't need a Node server for that!


4 Answers

  1. VueJS app is not NodeJS app.
  2. VueJS app is interpreted by the browser.
  3. You just have to build your app on computer and host files as any static website, so any server can serve html and files.
  4. To build your app use e.g. Webpack (https://github.com/vuejs-templates/webpack )
like image 61
Marek Urbanowicz Avatar answered Oct 25 '22 21:10

Marek Urbanowicz


NodeJs only use to build *.js files in front-end, your WebApp dosen't have to run on Nodejs.

1, You can create a index.html file that requires *.js file when webpack built it.

2, Use Chrome to open your index.html file so you can see it works.

You don't need to use vue-cli or other servers if you only want a static page.

But you have to know how to set your webpack.config.js, you can look that doc https://webpack.js.org/guides/getting-started/

like image 9
Simon.Lay Avatar answered Oct 25 '22 21:10

Simon.Lay


Your starting point is wrong. Vue + node.js can build a complete site. Vue is the front-end framework, node's server language. The two can be used in combination. But not vue must rely on node to use. The two of them can be perfect to achieve the front and back separation of the development model.

In projects that use vue, individuals do not recommend configuring webpack and vue-loader separately. You can directly use vue official scaffolding, vue-cli. Do not have to consider these configurations, automatically configured.

Vue-cli

If you just started learning Vue, here's an entry-level demo. Although it is only a small application, but it covers a lot of knowledge points (vue2.0 + vue-cli + vue-router + vuex + axios + mysql + express + pm2 + webpack), including front-end, back-end, database and other sites Some of the necessary elements, for me, learning great significance, would like to encourage each other!

Vue Demo

like image 3
AlloyTeamZy Avatar answered Oct 25 '22 20:10

AlloyTeamZy


Best way to develop Vue app is run dev server, and after all just build static assets. You don't need use vuex files, even better is use static template because you can easily integrate it with some back-end (WordPress or whatever). Helpfully will be use some starter, for ex. Vue.js starter

like image 2
Sabre Avatar answered Oct 25 '22 19:10

Sabre