Webpack basic set up with ES6
Start of by ensuring you have node, and webpack and webkit server installed on your system.
File set up
This is a simple set up. It resolves the paths so we can use the public directory and webpack knows where everything is when it builds and runs. It has watches our files and runs babel so we can use es6.
This files is required when using babel it tells it what version of ecma script to compile out to. When this runs it will create bundle.js in our route.
Here is a package.json file to use with working dependencies. It has babel, webpack and jslint
The app.js file in this example imports a function called “login” from our module1 file. This is the module import syntax from ES6.
This file imports a variable called ‘testing’ from module2.js and it also exports itself so it can be imported into app.js.
This module is just used to export a variable to show an example of how you could use it.
To run this set up type ‘npm start’ this looks at the package.json and we have set a option called start. This runs ‘webpack-dev-server -d’ which fires up the server and waits for changes.