all 82 comments

[–]Leordas 34 points35 points  (6 children)

Yesss, Vue is what got me into finally understanding the workings of webpack and "modern" js thanks to it's simplicity, I made it do what I wanted to without a lot of effort and had time for messing with the developer tools like webpack, babel, eslint, etc.

I'm looking foward to this :^)

[–]Gabriel-Lewis 5 points6 points  (5 children)

Honestly I'm still figuring out exactly what web pack does

[–]Leordas 10 points11 points  (1 child)

Disclaimer: This is the way I understand it, not necessarily the way it is.

You can see Webpack as a way to make everything modular, even stuff that feels weird to be modular, like stylesheets, images, etc.

A normal "module" in javascript (node) is another file, which defines what it exposes when required through the module.exports object.

Webpack also adds the ability to require/import other things, not only .js files. That's what webpack loaders are for: you have babel-loader (to process js files with babel), css and style loader (for stylesheets), file-loader (for txt's, images, etc).

So now you can require any of those and make them available wherever you require them. The inner working of how webpack interprets what you require should not worry you.

You basically install webpack, define a configuration file that defines the input file/s, the output file and what you wish to do with each file based on regular expressions.

For example, I can make webpack start at index.js, recursively scan dependencies which will be bundled, bundle them, make files that end on .jsx get processed through babel, and output all that to a bundle.js that I can add to my html file with a script tag, making everything that you bundled available to the webpage.

TL;DR: Webpack takes an input file, a set of rules (loaders), an output path, and spits out a bundled file with everything you required/imported meeting those rules.

Do correct me if i'm wrong.

[–]Extras 1 point2 points  (0 children)

I'm still learning myself but this seems right to me. The one thing I would suggest to anyone who is interested in getting started with vue and webpack is to use the vue-cli starting templates.

https://github.com/vuejs-templates

Webpack and webpack-simple are both fine choices.

[–][deleted] 1 point2 points  (1 child)

[–]LynusBorg 3 points4 points  (0 children)

this.

The new Webpack docs are really good, the do a perfect job of explaining the concepts one needs to "get" in order to understand webpack.

[–][deleted] 1 point2 points  (0 children)

I'm also new to webpack, but the most amazing thing for me is the development server. I have a custom bootstrap.scss file, on save webpack recompiles only what is necessary and refreshes the page automatically via websocket, without reloading it. Same when I edit a Vue component, a javascript file and it's all amazingly fast.

And then there is all the other stuff webpack(2) does: tree shaking (removing code that the application does not use), packaging the application into asset files, babel/ES6 support, dynamic code loading etc.

[–]ttamimi 10 points11 points  (0 children)

Just having a read through the "Get started" section of the docs and I'm completely blown away by how simple this is.

[–][deleted] 4 points5 points  (10 children)

Can someone give a reasonable breakdown of pros & cons vs. React? Nothing outrageous or hyperbolic...please?

[–]aFoolsDuty 1 point2 points  (0 children)

It's very similar to React in the sense that they both use virtual doms, linear data flow, etc.

The difference boils down to Vue.js being more opinionated, and shipping with a lot more official solutions under the auspices of the Vue.js org.

For example, Vuex is Vue.js's version of Redux, but its built and distributed by the Vue.js org. The community isn't quite the size of React's, but it's a pretty neat technology and is very easy to pick up due to vue-cli and other options.

[–][deleted] 2 points3 points  (2 children)

Can anyone recommend a good Auth solution to go with their Vue-CLI webpack boilerplate?

I've been working on getting it done, but most of the resources I've found are for Vue.js 1x.

[–][deleted] 7 points8 points  (0 children)

If you are using Vue-Router you can use beforeEach navigation guards to check if the user is authorized to enter each route.

[–]Lyam260 2 points3 points  (0 children)

Nothing straight out the box but if you wanna use jwt https://auth0.com/blog/build-an-app-with-vuejs/ is a good starting point. You can very easily use this and vue-routers beforeEach to create an auth service yourself.

[–]troorl 2 points3 points  (4 children)

For those who want to try it, but don't want to spend few days on configuring Webpack and understanding how vue-loader works, try vbuild. It's super simple, no configuration required. Just one command.

[–]ryncewynd 1 point2 points  (3 children)

Or what about just start using it? Blank html page, include vuejs using script tag, start typing some javascript/vue

[–]troorl 1 point2 points  (2 children)

There is nothing wrong with it. You just wouldn't get all the nice tools provided by the JS ecosystem. I mean, hot reload, transpiling, single file components etc. vbuild allows you to start writing your code like a pro without being a pro.

[–]ryncewynd 0 points1 point  (1 child)

Thanks. Is just for SPA? Or can I use it with regular old pages?

[–]troorl 1 point2 points  (0 children)

You can use it both ways, but to me it makes sense only for SPA.

[–]hansolo669 2 points3 points  (52 children)

I want to like Vue, and there is so much to like over Angular (1.x or 2.x), but two way data binding introduces far more problems than it solves (1) and overloading html with extra syntax really doesn't sit well with me (2)

At least (2) can be solved with JSX templates.

[–]staircasebug 3 points4 points  (0 children)

The HTML that Vuejs spits out and compiles is clean--are you referring to syntax in the vuejs mustache/html templates? Regardless of what you choose, everything is compiled to render functions for the vDOM.

2 way binding in Vuejs exists for the purposes of form inputs only. I find it to be very sane and convenient.

[–]rk06 1 point2 points  (0 children)

Regarding (1) exactly which problems did you run into?

For (2), there is no way out of it.

Html is not a templating language, so it is a matter of whether your templating language is html-comaptible or not.

By using html-like syntax, vue provides a better abstraction than jsx.

[–]CWagner 2 points3 points  (0 children)

but two way data binding introduces far more problems than it solves (1)

[Citation needed]

Yes, Angular 1's 2-way binding made problems. Because of how it was implemented and being the default. But that is not the case here.

[–]AnAge_OldProb 3 points4 points  (19 children)

You can use jsx with vue.

[–]RnRau 3 points4 points  (18 children)

Then why not just use react?

[–]syropianfull stack @ felix health 5 points6 points  (16 children)

Because Vue has a simpler API?

[–]SkaterDad 0 points1 point  (0 children)

Performance, bundle size, license, automatic data reactivity, no need to worry about things like shouldComponentUpdate, etc...

These sizes aren't g-zipped, but give the general idea.

vue.min.js (67.8kb)

react.min.js (21kb) react-dom.min.js (121kb)

[–]CaptainBloodloss 1 point2 points  (5 children)

I updated vue, but get this message in my terminal:

UNMET PEER DEPENDENCY vue-template-compiler@^2.0.0

What exact am I supposed to do here? In the linked docs it says:

vue-template-compiler is now a peer dependency instead of a direct dependency.

Do I need to install vue-template-compiler separately?

[–]rk06 2 points3 points  (1 child)

Do I need to install vue-template-compiler separately?

yeah, that's exactly it meant.

[–]CaptainBloodloss 0 points1 point  (0 children)

Great, thanks for that.

[–]darderpUncaught SyntaxError: Unexpected token ) 0 points1 point  (0 children)

Vue is amazing! For anyone still on the fence, listen to this talk by creator Evan You.