Skip to content

Instantly share code, notes, and snippets.

@sizief
Last active October 5, 2019 22:29
Show Gist options
  • Save sizief/8d8057686eb003d7281615be14157826 to your computer and use it in GitHub Desktop.
Save sizief/8d8057686eb003d7281615be14157826 to your computer and use it in GitHub Desktop.
Development
- $ npm init -y
- $ npm install nodemon --save-dev
- $ npm install @babel/core @babel/cli @babel/node @babel/preset-env --save-dev
- `.babelrc` -> `{"presets": ["@babel/preset-env"]}`
- `package.json` -> `"scripts": {"build":"babel src -d dist"}`
- `package.json` -> `"scripts": {"start":"nodemon --exec babel-node src/file.js"}`
or following line is the same. But note that following line is NOT restart the the output based on code changes.
- `package.json` -> `"start": "npm run build && nodemon dist/todo_store.js"`
- $ npm start
Production for node (This will not bundle dependecies in one file, you will get `require not defined` error if run it on browser.)
- $ npm run build
- $ node dist/file.js
Production for browser
- $ browserify dist/compiled.js -o bundle.js
- insert into HTML `<script src="bundle.js"></script>`
For `Mobx` add this to `.babelrc`:
```
{
"presets": ["@babel/preset-env"],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose": true }]
]
}
```
---
Webpack
- npm install webpack --save-dev
- npm install webpack-cli --save-dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment