@@ -42,13 +42,13 @@ What belongs in your JavaScript Starter Kit?
42
42
43
43
### JavaScript Editors
44
44
45
- - Atom
45
+ - #### Atom
46
46
47
- - WebStorm ** (author's favorite)**
47
+ - #### WebStorm ** (author's favorite)**
48
48
49
- - Brackets
49
+ - #### Brackets
50
50
51
- - VSCode ** (author's choice)**
51
+ - #### VSCode ** (author's choice)**
52
52
53
53
54
54
### EditorConfig
@@ -66,20 +66,27 @@ Selected npm, pretty much the defacto standard now
66
66
67
67
### Security Scanning for Packages
68
68
69
- - retire.js
70
- - Node Security Platform ** (author's choice)**
71
- - nsp check
69
+ - #### retire.js
70
+
71
+ - #### Node Security Platform ** (author's choice)**
72
+
73
+ - ` nsp check `
72
74
73
75
74
76
## Module #4 : Development Webserver
75
77
76
- - http-server
78
+ - #### http-server
79
+
77
80
- Ultra-simple
78
81
- Single command serves up server
79
- - live-server
82
+
83
+ - #### live-server
84
+
80
85
- Lightweight
81
86
- Support live-reloading
82
- - Express ** (author's choice)**
87
+
88
+ - #### Express ** (author's choice)**
89
+
83
90
- Comprehensive
84
91
- Highly configurable
85
92
- Not just for static files
@@ -89,14 +96,20 @@ Selected npm, pretty much the defacto standard now
89
96
- Alternatives:
90
97
- koa
91
98
- hapi
92
- - budo
99
+
100
+ - #### budo
101
+
93
102
- Integrates with Browserify
94
103
- Includes hot reloading
95
- - Webpack dev server
104
+
105
+ - #### Webpack dev server
106
+
96
107
- Built in to Webpack
97
108
- Serves from memory
98
109
- Includes hot reloading
99
- - Browsersync
110
+
111
+ - #### Browsersync
112
+
100
113
- Dedicated IP for sharing work on LAN
101
114
- All interactions remain in sync
102
115
- Across devices, etc.
@@ -115,38 +128,141 @@ Used `node .\buildScripts\srcServer.js` command to leverage our script to run Ex
115
128
116
129
Alternatives to using traditional Cloud services such as AWS and Azure.
117
130
118
- - localtunnel ** (author's choice)**
131
+ - #### localtunnel ** (author's choice)**
132
+
119
133
- Easily share work on your local machine
120
- - npm install localtunnel -g
134
+ - ` npm install localtunnel -g `
121
135
- start your app
122
- - lt --port 3000 --subdomain kevin
136
+ - ` lt --port 3000 --subdomain kevin `
123
137
- Creates: http://kevin.localtunnel.me
124
- - ngrok
138
+
139
+ - #### ngrok
140
+
125
141
- Secure tunnel to your local machine
126
142
- Pretty easy to share work
127
143
- Install ngrok
128
144
- Install authtoken
129
145
- Start your app
130
- - ./ngrok http 80
146
+ - ` ./ngrok http 80 `
131
147
- Secure
132
- - Surge
148
+
149
+ - #### Surge
150
+
133
151
- Quickly host static files to public URL
134
152
- Setup
135
- - npm install -g surge
136
- - surge
153
+ - ` npm install -g surge `
154
+ - ` surge `
137
155
- Different approach
138
156
- Hosting persists
139
- - now
157
+
158
+ - #### now
159
+
140
160
- Quickly deploy Node.js to the cloud
141
161
- To use
142
- - npm install -g now
162
+ - ` npm install -g now `
143
163
- Create start script
144
164
- now
145
165
- Hosting persists
146
166
147
167
## Module #5 : Automation
148
168
169
+ - #### Grunt
170
+
171
+ - the "original"
172
+ - configuration over code
173
+ - writes intermediary files between steps
174
+ - large plugin ecosystem
175
+
176
+ - #### Gulp
177
+
178
+ - in-memory streams; pipes
179
+ - no files
180
+ - fast
181
+ - code over configuration; code-based
182
+ - large plugin ecosystem
183
+
184
+ - #### npm Scripts ** (author's choice)**
185
+
186
+ - declared in package.json
187
+ - leverage your OS' command line
188
+ - directly use npm packages
189
+ - call separate Node scripts
190
+ - convention-based pre/post hooks
191
+ - leverage world's largest package manager
192
+
193
+ ### Why npm Scripts (over Gulp)?
194
+
195
+ - Use tools directly
196
+ - No need for separate plugins
197
+ - Simpler debugging
198
+ - Better documentation
199
+ - Easy to learn
200
+ - Simple
201
+
202
+ Author wrote interesting article on why he migrated from Gulp to npm Scripts:
203
+
204
+ [ bit.ly/npmvsgulp] ( bit.ly/npmvsgulp )
205
+
206
+ ### npm Scripts
207
+
208
+ #### package.json Changes
209
+
210
+ All of these changes are to be made in the "scripts" block near the top of the file.
211
+
212
+ - Add start:
213
+
214
+ ``` javascript
215
+ " start" : " node buildScripts/srcServer.js"
216
+ ```
217
+
218
+ - ` npm start ` to start up the local webserver
219
+
220
+ - Add prestart:
221
+
222
+ ``` javascript
223
+ " prestart" : " node buildScripts/startMessage.js"
224
+ ```
225
+
226
+ - This script uses a library called Chalk to add a colored message to the console when we run npm start
227
+
228
+ - Add security-check (nsp):
229
+
230
+ ``` javascript
231
+ " security-check" : " nsp check"
232
+ ```
233
+
234
+ - ` npm run security-check `
235
+ - Note: npm start, npm test are the * only* commands where you can avoid typing ** run**
236
+
237
+ - Add share (localtunnel):
238
+
239
+ ``` javascript
240
+ " share" : " lt --port 3000 --subdomain kevin"
241
+ ```
242
+
243
+ - ` npm run share `
244
+ - This will launch ` http://kevin.localtunnel.me `
245
+
246
+ - Add "open: src " and Update "start" (npm-run-all):
247
+
248
+ ``` javascript
249
+ " start" : " npm-run-all --parallel security-check open:src"
250
+ " open:src" : " node buildScripts/srcServer.js"
251
+ ```
252
+ - Note: ` npm-run-all ` allows us to run 1-n of the scripts in parallel
253
+
254
+ - Add "localtunnel" and Update "share" (npm-run-all)
255
+
256
+ ``` javascript
257
+ " localtunnel" : " lt --port 3000 --subdomain kevin"
258
+ " share" : " npm-run-all --parallel open:src localtunnel"
259
+ ```
260
+ - ` npm run share ` now starts up our server and exposes it via localtunnel all at once!
261
+
262
+ #### Conventions:
149
263
264
+ - In an npm script, like package.json (above), we can append the prefixes "pre" and "post" to a given script in order to run another script before (pre) or after (post)
265
+ - Examples: "prestart" - will get run * before* "start", "poststart" - will get run * after* "start"
150
266
151
267
## Bibliography
152
268
0 commit comments