$ nvm i 8
$ npm i breathecode-cli -g
$ bc start:react -r
$ npm install
Start coding your ReactJS application.
Note: If you ever want to manually install all of this read the MANUAL.md file.
Now you have an index.js that will start your javascript execution (like the window.onload).
$ npm run build
Check that a public/bundle.js file has been created by Webpack. Read the output from the console that must be similar to this:
> [email protected] transpile-dev /home/ubuntu/workspace
> webpack --config webpack.config.js
Hash: 64f06c46f625967b3aeb
Version: webpack 3.8.1
Time: 99ms
Asset Size Chunks Chunk Names
bundle.js 2.52 kB 0 [emitted] main
[0] ./src/bundle.js 51 bytes {0} [built]
You are ready to go! You can commit & push to your new repository whenever you want.
The application flow starts at index.js, you have to import any other files or assets into app.js in order for webpack to include them in the bundle.
For example, inside index.js you can do:
window.onload = function(){
console.log('hello world');
}
To include images, styles or any other type of file just use the import command:
//This will include file.js into your bundle.
import 'js/file2.js';
//this will include the styles at index.scss to your bundle.
import '../styles/index.scss';
-
All your JS and CSS code must go inside the src/ directory, and webpack will automaticly bundle them and export them into the public folder.
-
The HTML code must be inside public/index.html