Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tip for the webpack chapter #6

Closed
UnsungHero97 opened this issue Oct 11, 2016 · 5 comments
Closed

tip for the webpack chapter #6

UnsungHero97 opened this issue Oct 11, 2016 · 5 comments

Comments

@UnsungHero97
Copy link

It might be useful to add a tip to the webpack chapter about using ES6 syntax for webpack.config.js. All it takes is to rename the file to webpack.config.babel.js, and then you use standard ES6 syntax, including import and export:

import Webpack from 'webpack';

import pkg from './package.json';

...

export default {
  entry: ...,
  output: { ... },
  module: { ... },
  ...
}
@verekia
Copy link
Owner

verekia commented Oct 11, 2016

I didn't know that, thanks for the tip! Will update the tutorial asap. I found that it's also possible with gulpfile.babel.js, pretty neat :)

@verekia
Copy link
Owner

verekia commented Oct 11, 2016

Fixed! Thank you very much :)

@verekia verekia closed this as completed Oct 11, 2016
@UnsungHero97
Copy link
Author

Anytime :) I just went through this exercise not too long ago... was a bit overwhelmed by everything. There's certainly a place for a well put-together guide on getting started with a modern JS stack, or rather, putting one together from scratch.

@saitonakamura
Copy link

ES6 is awesome but using import can cause problems.
For example this file is executed by node, like node --harmony server.js and I'm using it to enable hot reloading.
But I can't use import in here because node harmony mode does not support import and the main cause of this that there is problems with implementation import in V8, see this thread.
So I'm still using require in code that executes on server (such as using js wrappers for webpack, webpack-dev-middleware, webpack-hot-middleware) and recommend you to do so.
AFAIK you can use export, but I find it violating the POLA to use export and not to use import in one file.
Other cool features like const, let are available using --harmony flag by the way.

@verekia
Copy link
Owner

verekia commented Oct 19, 2016

@saitonakamura This is why I use Babel on the server as well. Every import in this tutorial ends up as a require in the lib directory, even server code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants