Skip to content

Commit 9814486

Browse files
dhruvduttmontogeek
authored andcommitted
docs(): Merge the next branch (#1993)
* docs(guides) Fix error with filename + npm package. (#1886) 1) Webpack as default build to file main.js , not on bundle.js. 2) Add npm install webpack-cli -D to npm install, If you do not do this console throw next: ====================================================== The CLI moved into a separate package: webpack-cli. Please install 'webpack-cli' in addition to webpack itself to use the CLI. -> When using npm: npm install webpack-cli -D -> When using yarn: yarn add webpack-cli -D ====================================================== So pls fix this, thank`s. * docs(guides): Added info for v4 and webpack-cli (#1888) * docs(configuration) Update snippets to comply with webpack v4+ (#1905) * docs(configuration) Update snippets to comply with webpack v4+ * Expand mode for more info * fix(docs) Remove git conflict
1 parent 5091d81 commit 9814486

File tree

10 files changed

+141
-101
lines changed

10 files changed

+141
-101
lines changed

Diff for: .gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ starter-kits-data.json
77
.antwar
88
.vscode
99
.idea
10-
.DS_Store
10+
.DS_Store

Diff for: src/content/api/plugins.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,5 @@ different hook classes and how they work.
9696

9797
## Next Steps
9898

99-
See the [compiler hooks](https://webpack.js.org/api/compiler-hooks/) section for a detailed listing of all the available
99+
See the [compiler hooks](/api/compiler-hooks/) section for a detailed listing of all the available
100100
`compiler` hooks and the parameters they make available.

Diff for: src/content/concepts/configuration.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ T> The most important part to take away from this document is that there are man
2828

2929
The following examples below describe how webpack's configuration object can be both expressive and configurable because _it is code_:
3030

31-
## The Simplest Configuration
31+
## Simple Configuration
3232

3333
**webpack.config.js**
3434

3535
```javascript
3636
var path = require('path');
3737

3838
module.exports = {
39+
mode: 'development',
3940
entry: './foo.js',
4041
output: {
4142
path: path.resolve(__dirname, 'dist'),

Diff for: src/content/configuration/configuration-languages.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import path from 'path';
3030
import webpack from 'webpack';
3131

3232
const config: webpack.Configuration = {
33+
mode: 'production',
3334
entry: './foo.js',
3435
output: {
3536
path: path.resolve(__dirname, 'dist'),
@@ -103,6 +104,7 @@ webpack = require('webpack')
103104
path = require('path')
104105

105106
config =
107+
mode: 'production'
106108
entry: './path/to/my/entry/file.js'
107109
output:
108110
path: path.resolve(__dirname, 'dist')
@@ -152,7 +154,7 @@ const CustomPlugin = config => ({
152154
});
153155

154156
export default (
155-
<webpack target="web" watch>
157+
<webpack target="web" watch mode="production">
156158
<entry path="src/index.js" />
157159
<resolve>
158160
<alias {...{

Diff for: src/content/configuration/configuration-types.md

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ One option is to export a function from your webpack config instead of exporting
2424
-module.exports = {
2525
+module.exports = function(env, argv) {
2626
+ return {
27+
+ mode: env.production ? 'production' : 'development',
2728
+ devtool: env.production ? 'source-maps' : 'eval',
2829
plugins: [
2930
new webpack.optimize.UglifyJsPlugin({
@@ -64,11 +65,13 @@ module.exports = [{
6465
libraryTarget: 'amd'
6566
},
6667
entry: './app.js',
68+
mode: 'production',
6769
}, {
6870
output: {
6971
filename: './dist-commonjs.js',
7072
libraryTarget: 'commonjs'
7173
},
7274
entry: './app.js',
75+
mode: 'production',
7376
}]
7477
```

Diff for: src/content/configuration/index.md

+7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ __webpack.config.js__
2929
const path = require('path');
3030
3131
module.exports = {
32+
<details><summary>[mode](/concepts/mode): "production", // "production" | "development" | "none"</summary>
33+
[mode](/concepts/mode): "production", // enable many optimizations for production builds
34+
[mode](/concepts/mode): "development", // enabled useful tools for development
35+
[mode](/concepts/mode): "none", // no defaults
36+
</details>
37+
// Chosen mode tells webpack to use its built-in optimizations accordingly.
38+
3239
<details><summary>[entry](/configuration/entry-context#entry): "./app/entry", // string | object | array</summary>
3340
[entry](/configuration/entry-context#entry): ["./app/entry1", "./app/entry2"],
3441
[entry](/configuration/entry-context#entry): {

Diff for: src/content/guides/getting-started.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Version: webpack 4.0.1
184184
Time: 3003ms
185185
Built at: 2018-2-26 22:42:11
186186
Asset Size Chunks Chunk Names
187-
bundle.js 69.6 KiB 0 [emitted] main
187+
main.js 69.6 KiB 0 [emitted] main
188188
Entrypoint main = main.js
189189
[1] (webpack)/buildin/module.js 519 bytes {0} [built]
190190
[2] (webpack)/buildin/global.js 509 bytes {0} [built]

Diff for: src/content/guides/installation.md

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ npm install --save-dev webpack
2828
npm install --save-dev webpack@<version>
2929
```
3030

31+
If you're using webpack 4 or later, you'll also need to install the CLI.
32+
33+
``` bash
34+
npm install --save-dev webpack-cli
35+
```
36+
3137
Installing locally is what we recommend for most projects. This makes it easier to upgrade projects individually when breaking changes are introduced. Typically webpack is run via one or more [npm scripts](https://docs.npmjs.com/misc/scripts) which will look for a webpack installation in your local `node_modules` directory:
3238

3339
```json

Diff for: src/content/index.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: webpack
66

77
<div class="splash__wrap">
88
<div class="splash__left">
9-
__app.js__
9+
__src/index.js__
1010

1111
```js
1212
import bar from './bar';
@@ -15,7 +15,7 @@ bar();
1515
```
1616
</div>
1717
<div class="splash__right">
18-
__bar.js__
18+
__src/bar.js__
1919

2020
```js
2121
export default function bar() {
@@ -30,12 +30,15 @@ export default function bar() {
3030

3131
<div class="splash__wrap">
3232
<div class="splash__left">
33-
__webpack.config.js__
33+
__[Without config](https://youtu.be/3Nv9muOkb6k?t=21293)__ or provide custom __webpack.config.js__
3434

3535
```js
36+
const path = require('path');
37+
3638
module.exports = {
37-
entry: './app.js',
39+
entry: './src/index.js',
3840
output: {
41+
path: path.resolve(__dirname, 'dist'),
3942
filename: 'bundle.js'
4043
}
4144
};
@@ -52,7 +55,7 @@ __page.html__
5255
</head>
5356
<body>
5457
...
55-
<script src="bundle.js"></script>
58+
<script src="dist/bundle.js"></script>
5659
</body>
5760
</html>
5861
```

0 commit comments

Comments
 (0)