Skip to content

Commit 2e25b9a

Browse files
committed
not needed to type the path for scripts inside package.json
1 parent 483c132 commit 2e25b9a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

materials/appendixA/index.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,15 @@ <h1 id="configuringwebpack">Configuring Webpack</h1>
236236
<h2 id="addingtask">Adding task Shortcuts</h2>
237237

238238
<p>Executing a long command such as "node_modules/.bin/webpack" is boring and error prone. Thankfully, npm can be used as a task runner, hiding verbose scripts under simple commands such as "npm start". This can be achieved easily by setting up a scripts section to package.json, as shown below:</p>
239+
<p>Notice that all scripts configured in the package.json file already have the “node_modules/.bin” folder in the path, so you don’t need to explicitly call the desired command with the full path.</p>
239240

240241
<p><pre><code>
241242
{
242243
&quot;name&quot;: &quot;webpack-sample-project&quot;,
243244
&quot;version&quot;: &quot;1.0.0&quot;,
244245
&quot;description&quot;: &quot;Sample webpack project&quot;,
245246
&quot;scripts&quot;: {
246-
&quot;start&quot;: &quot;node_modules/.bin/webpack&quot;
247+
&quot;start&quot;: &quot;webpack&quot;
247248
},
248249
&quot;author&quot;: &quot;C&aacute;ssio Zen&quot;,
249250
&quot;license&quot;: &quot;ISC&quot;,
@@ -426,19 +427,19 @@ <h1 id="webpackdevelopment">Webpack Development Server</h1>
426427
}
427428
</code></pre></p>
428429

429-
<p>Instead of running the webpack command, now you will execute the "webpack-dev-server" to start the server. As you did previously, you will need to specify the path to the executable inside your project's node modules:</p>
430+
<p>Instead of running the webpack command, now you will execute the "webpack-dev-server" to start the server:</p>
430431

431432
<p><pre><code class='bash'>node_modules/.bin/webpack-dev-server</code></pre></p>
432433

433-
<p>For convenience, you can edit the "scripts" section in your project's package.json file to run the server by invoking "npm start", as shown below:</p>
434+
<p>For convenience, you can edit the "scripts" section in your project's package.json file to run the server by invoking "npm start", as shown below (remember that it’s not necessary to fill the complete path to “node_modules/.bin” inside the scripts section):</p>
434435

435436
<p><pre><code>
436437
{
437438
&quot;name&quot;: &quot;webpack-sample-project&quot;,
438439
&quot;version&quot;: &quot;1.0.0&quot;,
439440
&quot;description&quot;: &quot;Sample webpack project&quot;,
440441
<strong>&quot;scripts&quot;: {
441-
&quot;start&quot;: &quot;node_modules/.bin/webpack-dev-server --progress&quot;
442+
&quot;start&quot;: &quot;webpack-dev-server --progress&quot;
442443
},</strong>
443444
&quot;author&quot;: &quot;C&aacute;ssio Zen&quot;,
444445
&quot;license&quot;: &quot;ISC&quot;,
@@ -1187,8 +1188,8 @@ <h1 id="buildingfor">Building for production</h1>
11871188
&quot;version&quot;: &quot;1.0.0&quot;,
11881189
&quot;description&quot;: &quot;Sample webpack project&quot;,
11891190
&quot;scripts&quot;: {
1190-
&quot;start&quot;: &quot;node_modules/.bin/webpack-dev-server --progress&quot;,
1191-
<strong>&quot;build&quot;: &quot;NODE_ENV=production node_modules/.bin/webpack &#x2013;config ./webpack.production.config.js --progress&quot;</strong>
1191+
&quot;start&quot;: &quot;webpack-dev-server --progress&quot;,
1192+
<strong>&quot;build&quot;: &quot;NODE_ENV=production webpack -config ./webpack.production.config.js --progress&quot;</strong>
11921193
},
11931194
&quot;author&quot;: &quot;C&aacute;ssio Zen&quot;,
11941195
&quot;license&quot;: &quot;ISC&quot;,

0 commit comments

Comments
 (0)