Skip to content

Commit 3a52474

Browse files
resolves #727
1 parent 6540bbf commit 3a52474

File tree

8 files changed

+38
-19
lines changed

8 files changed

+38
-19
lines changed

content/concepts/index.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ contributors:
55
- TheLarkInn
66
- jhnns
77
- grgur
8+
- johnstew
89
---
910

1011
*webpack* is a _module bundler_ for modern JavaScript applications. It is [incredibly configurable](/configuration), however, there are **Four Core Concepts** we feel you should understand before you get started!
@@ -111,12 +112,13 @@ In order to use a plugin, you just need to `require()` it and add it to the `plu
111112
```javascript
112113
const HtmlWebpackPlugin = require('html-webpack-plugin'); //installed via npm
113114
const webpack = require('webpack'); //to access built-in plugins
115+
const path = require('path');
114116

115117
const config = {
116118
entry: './path/to/my/entry/file.js',
117119
output: {
118-
filename: 'my-first-webpack.bundle.js',
119-
path: './dist'
120+
path: path.resolve(__dirname, 'dist'),
121+
filename: 'my-first-webpack.bundle.js'
120122
},
121123
module: {
122124
rules: [

content/concepts/plugins.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ contributors:
55
- TheLarkInn
66
- jhnns
77
- rouzbeh84
8+
- johnstew
89
---
910

1011
**Plugins** are the [backbone](https://github.com/webpack/tapable) of webpack. webpack itself is built on the **same plugin system** that you use in your webpack configuration!
@@ -46,12 +47,13 @@ Depending on how you are using webpack, there are multiple ways to use plugins.
4647
```javascript
4748
const HtmlWebpackPlugin = require('html-webpack-plugin'); //installed via npm
4849
const webpack = require('webpack'); //to access built-in plugins
50+
const path = require('path');
4951

5052
const config = {
5153
entry: './path/to/my/entry/file.js',
5254
output: {
5355
filename: 'my-first-webpack.bundle.js',
54-
path: './dist'
56+
path: path.resolve(__dirname, 'dist')
5557
},
5658
module: {
5759
rules: [

content/concepts/targets.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ sort: 10
44
contributors:
55
- TheLarkInn
66
- rouzbeh84
7+
- johnstew
78
---
89

910
Because JavaScript can be written for both server and browser, webpack offers multiple deployment _targets_ that you can set in your webpack [configuration](/configuration).
@@ -35,10 +36,11 @@ Although webpack does **not** support multiple strings being passed into the `ta
3536
**webpack.config.js**
3637

3738
```javascript
39+
var path = require('path');
3840
var serverConfig = {
3941
target: 'node',
4042
output: {
41-
path: 'dist',
43+
path: path.resolve(__dirname, 'dist'),
4244
filename: 'lib.node.js'
4345
}
4446
//
@@ -47,7 +49,7 @@ var serverConfig = {
4749
var clientConfig = {
4850
target: 'web', // <=== can be omitted as default is 'web'
4951
output: {
50-
path: 'dist',
52+
path: path.resolve(__dirname, 'dist'),
5153
filename: 'lib.js'
5254
}
5355
//

content/get-started/index.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ contributors:
66
- varunjayaraman
77
- cntanglijun
88
- chrisVillanueva
9+
- johnstew
910
---
1011

1112
webpack is a tool to build JavaScript modules in your application. To start using `webpack` from its [cli](/api/cli) or [api](/api/node), follow the [Installation instructions](/get-started/install-webpack).
@@ -126,13 +127,15 @@ with the following config settings.
126127

127128
__webpack.config.js__
128129
```javascript
130+
var path = require('path');
131+
129132
module.exports = {
130133
entry: './app/index.js',
131134
output: {
132135
filename: 'bundle.js',
133-
path: './dist'
136+
path: path.resolve(__dirname, 'dist')
134137
}
135-
}
138+
};
136139
```
137140

138141
This file can be run by webpack as follows.
@@ -176,4 +179,3 @@ T> You can pass custom parameters to webpack by adding two dashes to the `npm ru
176179
## Conclusion
177180

178181
Now that you have a basic build together, you should dig into the [basic concepts](/concepts) and [configuration](/configuration) of webpack to better understand its design. Also check out the [guides](/guides) to learn how to approach common problems. The [API](/api) section digs into the lower level features.
179-

content/guides/author-libraries.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: Authoring Libraries
33
sort: 18
44
contributors:
55
- pksjce
6+
- johnstew
67
---
78

89
webpack is a tool which can be used to bundle application code and also to bundle library code. If you are the author of a JavaScript library and are looking to streamline your bundle strategy then this document will help you.
@@ -80,11 +81,12 @@ Add basic webpack configuration.
8081
__webpack.config.js__
8182

8283
```javascript
84+
var path = require('path');
8385

8486
module.exports = {
8587
entry: './src/index.js',
8688
output: {
87-
path: './dist',
89+
path: path.resolve(__dirname, 'dist'),
8890
filename: 'webpack-numbers.js'
8991
}
9092
};

content/guides/code-splitting-css.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ sort: 3
44
contributors:
55
- pksjce
66
- jonwheeler
7+
- johnstew
78
---
89

910
In webpack, when you use the css-loader and import CSS into your JavaScript files, the CSS is bundled along with your JavaScript.
@@ -63,11 +64,13 @@ The full config for splitting css with `ExtractTextPlugin` is as follows
6364

6465
```javascript
6566
var ExtractTextPlugin = require('extract-text-webpack-plugin');
67+
var path = require('path');
68+
6669
module.exports = function () {
6770
return {
6871
entry: './main.js',
6972
output: {
70-
path: './dist',
73+
path: path.resolve(__dirname, 'dist'),
7174
filename: 'bundle.js'
7275
},
7376
module: {

content/guides/code-splitting-libraries.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ sort: 4
44
contributors:
55
- pksjce
66
- chrisVillanueva
7+
- johnstew
78
---
89

910
A typical application uses third party libraries for framework/functionality needs. Particular versions of these libraries are used and code here does not change often. However, the application code changes frequently.
@@ -22,7 +23,6 @@ The index file will require `moment` as a dependency and log the current date as
2223

2324
__index.js__
2425
```javascript
25-
2626
var moment = require('moment');
2727
console.log(moment().format());
2828

@@ -33,13 +33,14 @@ We can bundle the application with webpack using the following config
3333
__webpack.config.js__
3434

3535
```javascript
36+
var path = require('path');
3637

3738
module.exports = function(env) {
3839
return {
3940
entry: './index.js',
4041
output: {
4142
filename: '[chunkhash].[name].js',
42-
path: './dist'
43+
path: path.resolve(__dirname, 'dist')
4344
}
4445
}
4546
}
@@ -56,6 +57,7 @@ Let's try to mitigate this by adding a separate entry point for `moment` and nam
5657
__webpack.config.js__
5758

5859
```javascript
60+
var path = require('path');
5961

6062
module.exports = function(env) {
6163
return {
@@ -65,7 +67,7 @@ module.exports = function(env) {
6567
},
6668
output: {
6769
filename: '[chunkhash].[name].js',
68-
path: './dist'
70+
path: path.resolve(__dirname, 'dist')
6971
}
7072
}
7173
}
@@ -84,8 +86,9 @@ We can modify our webpack config file to use the `CommonsChunkPlugin` as follows
8486
__webpack.config.js__
8587

8688
```javascript
87-
8889
var webpack = require('webpack');
90+
var path = require('path');
91+
8992
module.exports = function(env) {
9093
return {
9194
entry: {
@@ -94,7 +97,7 @@ module.exports = function(env) {
9497
},
9598
output: {
9699
filename: '[chunkhash].[name].js',
97-
path: './dist'
100+
path: path.resolve(__dirname, 'dist')
98101
},
99102
plugins: [
100103
new webpack.optimize.CommonsChunkPlugin({
@@ -118,8 +121,9 @@ To prevent this, we need extract out the runtime into a separate manifest file.
118121
__webpack.config.js__
119122

120123
```javascript
121-
122124
var webpack = require('webpack');
125+
var path = require('path');
126+
123127
module.exports = function(env) {
124128
return {
125129
entry: {
@@ -128,7 +132,7 @@ module.exports = function(env) {
128132
},
129133
output: {
130134
filename: '[chunkhash].[name].js',
131-
path: './dist'
135+
path: path.resolve(__dirname, 'dist')
132136
},
133137
plugins: [
134138
new webpack.optimize.CommonsChunkPlugin({

content/guides/code-splitting-require.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ sort: 5
44
contributors:
55
- pksjce
66
- rahulcs
7+
- johnstew
78
---
89

910
In this section, we will discuss how webpack splits code using `require.ensure()`.
@@ -38,7 +39,7 @@ Let us consider the following project
3839
| |-- b.js
3940
webpack.config.js
4041
|
41-
dist
42+
dist
4243
```
4344

4445
```javascript
@@ -58,13 +59,14 @@ console.log('***** I AM b *****');
5859

5960
```javascript
6061
\\ webpack.config.js
62+
var path = require('path');
6163

6264
module.exports = function(env) {
6365
return {
6466
entry: './js/entry.js',
6567
output: {
6668
filename: 'bundle.js',
67-
path: './dist'
69+
path: path.resolve(__dirname, 'dist')
6870
}
6971
}
7072
}

0 commit comments

Comments
 (0)