UNPKG

4.12 kBMarkdownView Raw
1# Nodify
2
3![nodify-status](https://david-dm.org/shrynx/nodify.svg?path=packages/nodify-core)
4[![npm version](https://badge.fury.io/js/nodify-core.svg)](https://badge.fury.io/js/nodify-core)
5
6Nodify is a build tool system for Node.js, allowing you to write next-generation
7Node.js applications with zero configuration.
8
9## Getting started
10
11### Assumptions
12
13Nodify assumes by default the entry point of your application to be
14`src/index.js` and will put output file in `build/main.js`, although everything
15is customizable.
16
17* * *
18
19### Installation
20
21Main package is named `nodify-core`, install it as a **devDependency** in your
22app.
23
24- via npm
25
26 ```shell
27 npm i -D nodify-core
28 ```
29
30- via yarn
31
32 ```shell
33 yarn add -D nodify-core
34 ```
35
36* * *
37
38### Usage
39
40Nodify is exposes two cli commands
41
42- ### **nodify dev**
43
44 Runs nodify in development mode. Allowing you to execute code and reload on
45
46 change, also providing helpful errors.
47 ![errors](https://user-images.githubusercontent.com/4706261/32256050-0fa77fa4-bef0-11e7-9326-e678cf7523ac.png)
48
49 **NOTE**: nodify dev automatically sets `process.env.node` to `development`,
50
51 and generates source map to support debugging.
52
53- ### **nodify build**
54
55 Builds app ready for production.
56
57 Build version will be outputted in `build/main.js`,
58
59 which you can run directly via node.
60
61 ```shell
62 node ./build/main
63 ```
64
65 **NOTE**: nodify build automatically sets `process.env.node` to `production`,
66
67 and doesn't generate any source maps.
68---
69
70Your `package.json` should look like
71
72```javascript
73{
74 ...
75
76 "scripts": {
77 "dev": "nodify dev",
78 "build": "nodify build",
79
80 ...
81 }
82
83 ...
84}
85```
86
87## Customization
88
89Under the hood nodify uses [rollup](https://rollupjs.org/) and
90[babel](https://babeljs.io/), which come pre-configured, but can with be
91completely customized.
92
93### Rollup
94
95To customize rollup config, create a `nodify.config.js` in the root directory of
96your app.
97
98```javascript
99module.exports = {
100 rollup: (config, env) => {
101 // access the config here
102 // also process.env.NODE_ENV can be accessed using env
103 // and customize it as you wish
104 // finally remember to return the modified config.
105 // by default during dev process.env.NODE_ENV is 'development'
106 // and during build process.env.NODE_ENV is 'production'
107 return config;
108 },
109};
110```
111
112Checkout the example for
113[custom rollup config](https://github.com/shrynx/nodify/tree/master/examples/custom-rollup)
114
115**NOTE**: The default config for rollup can be found [here](https://github.com/shrynx/nodify/blob/master/packages/nodify-core/config/rollup.config.js).
116
117### Babel
118
119To customize babel plugins and presets configuration, create a `.babelrc` file
120in the root directory of your app.
121
122If this file exists nodify will rely upon it rather than its internal
123configuration, therefore you must use nodify preset in your babelrc file, to
124make it work with nodify.
125
126Your `.babelrc` should look like
127
128```javascript
129{
130 "presets": [
131 "nodify-core/babel",
132 // add other presets
133 ],
134 "plugins": [
135 // add plugins
136 ]
137 ...
138}
139```
140
141Checkout the example for
142[custom babel config](https://github.com/shrynx/nodify/tree/master/examples/custom-babel)
143
144## Built with
145
146- [rollup](https://rollupjs.org/)
147- [babel](https://babeljs.io/)
148- [nodemon](https://nodemon.io/)
149
150## Examples
151
152Please refer the
153[examples](https://github.com/shrynx/nodify/tree/master/examples) folder for
154basic setups with different configurations.
155
156## Acknowledgement
157
158### Prior Art
159
160[Backpack](https://github.com/jaredpalmer/backpack) - Works in same way and uses
161`webpack`.
162
163### Inspiration
164
165- [backend-with-webpack](http://jlongster.com/Backend-Apps-with-Webpack--Part-I)
166 by [@jlongster](https://github.com/jlongster) for explaining the need of build
167 tools on node backend.
168
169- [create-react-app](https://github.com/facebookincubator/create-react-app) for
170 popularizing pre-configured tools that help jump start development.
171
172- [next.js](https://github.com/zeit/next.js) for creating customizable
173 configurations.
174
175## License
176
177MIT