Guest User

Untitled

a guest
Dec 17th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. ###### After `npm init` and you do all that noise, for setup
  2.  
  3. 1) `npm install --save-dev webpack webpack-dev-server babel-loader babel-core`
  4.  
  5. _Note: insert `react-hot-loader` and `react` etc, if you are working on React projects_
  6.  
  7. example: `npm install --save react react-dom history react-router`
  8.  
  9. 2) `touch webpack.config.js` and add this boilerplate:
  10.  
  11. ```module.exports = {
  12. entry: "./src/index.js",
  13. output: {
  14. path: __dirname + "/dist",
  15. filename: "bundle.js"
  16. },
  17. module: {
  18. loaders: [
  19. { test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" }
  20. ]
  21. },
  22. externals: {
  23. "jquery": "jQuery"
  24. }
  25. }
  26. ```
  27.  
  28. - Every JavaScript file will be processed by babel during the bundling
  29.  
  30. 3) Setup a preset
  31.  
  32. `npm install --save-dev babel-preset-latest`
  33.  
  34. 4) Create a file called `.bablerc` in project root. Paste this:
  35.  
  36. ```{
  37. "presets": ["latest"]
  38. }
  39. ```
  40.  
  41. 5) Open package.json and append:
  42.  
  43. ```"build": "webpack",
  44. "watch": "webpack --watch"```
  45.  
  46. 6) `npm install --save-dev node-sass`
  47.  
  48. and then add that compile to webpack command
  49.  
  50. 7) ```"build": "webpack && node-sass ./scss -o ./css && exit 0",
  51. "watch": "webpack --watch & node-sass --watch ./scss -o ./css"```
  52.  
  53. - for build, bundle the JS, compile the SCSS and then exit
  54. - for watch, both actions stay running indefinitely
Add Comment
Please, Sign In to add comment