Skip to content

Commit 8fe14fd

Browse files
authored
Merge pull request #312 from webpack/feature/code-samples
clean up some code samples
2 parents e9ccd53 + 829e42e commit 8fe14fd

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

content/concepts/configuration.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The following examples below describe how webpack's configuration object can be
1414
module.exports = {
1515
entry: './foo.js',
1616
output: {
17-
path: 'dist',
17+
path: path.resolve(__dirname, 'dist'),
1818
filename: 'foo.bundle.js'
1919
}
2020
};
@@ -36,7 +36,7 @@ var baseConfig = {
3636
},
3737
output: {
3838
filename: '[name].js',
39-
path: path.resolve(__dirname, './dist')
39+
path: path.resolve(__dirname, 'dist')
4040
},
4141
plugins: [
4242
new webpack.optimize.CommonsChunkPlugin({
@@ -55,7 +55,7 @@ let targets = ['web', 'webworker', 'node', 'async-node', 'node-webkit', 'electro
5555
let base = webpackMerge(baseConfig, {
5656
target: target,
5757
output: {
58-
path: path.resolve(__dirname, './dist/' + target),
58+
path: path.resolve(__dirname, 'dist/' + target),
5959
filename: '[name].' + target + '.js'
6060
}
6161
});
@@ -143,7 +143,7 @@ const CustomPlugin = config => ({
143143
name: 'custom-plugin'
144144
});
145145

146-
const CONFIG = (
146+
export default (
147147
<webpack target="web" watch>
148148
<entry path="src/index.js" />
149149
<resolve>
@@ -161,6 +161,4 @@ const CONFIG = (
161161
</plugins>
162162
</webpack>
163163
);
164-
165-
document.body.textContent = JSON.stringify(CONFIG, 0, ' ');
166164
```

content/how-to/author-libraries.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ The usage spec for the library will be as follows.
3636

3737
import * as webpackNumbers from 'webpack-numbers';
3838

39-
...
40-
webpackNumbers.wordToNum('Two') /// output is 2
41-
...
39+
...
40+
webpackNumbers.wordToNum('Two') // output is 2
41+
...
4242

4343
// CommonJs modules
4444

4545
var webpackNumbers = require('webpack-numbers');
46+
4647
...
4748
webpackNumbers.numToWord(3); // output is Three
4849
...

content/how-to/code-splitting/splitting-require.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ Let us consider the following project
4242
```javascript
4343
\\ entry.js
4444

45-
require('a')
45+
require('a');
4646
require.ensure([], function(require){
47-
require('b')
48-
})
47+
require('b');
48+
});
4949

5050
\\ a.js
51-
console.log('***** I AM a *****')
51+
console.log('***** I AM a *****');
5252

5353
\\ b.js
54-
console.log('***** I AM b *****')
54+
console.log('***** I AM b *****');
5555
```
5656

5757
```javascript
@@ -79,8 +79,8 @@ On running webpack on this project, we find that webpack has created two new bun
7979

8080
```javascript
8181
require.ensure([], function(require){
82-
require('./a.js')
83-
})
82+
require('./a.js');
83+
});
8484
```
8585

8686
The above code ensures that a split point is created and `a.js` is bundled separately by webpack.
@@ -90,7 +90,7 @@ The above code ensures that a split point is created and `a.js` is bundled separ
9090
```javascript
9191
require.ensure(['./a.js'], function(require) {
9292
require('./b.js');
93-
})
93+
});
9494
```
9595

9696
In the above code, `a.js` and `b.js` are bundled together and split from the main bundle. But only the contents of `b.js` are executed. The contents of `a.js` are only made available and not executed.

content/how-to/code-splitting/splitting-vendor.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ __index.js__
2222
```javascript
2323

2424
var moment = require('moment');
25-
console.log(moment().format())
25+
console.log(moment().format());
2626

2727
```
2828

@@ -134,7 +134,7 @@ modules.export = function(env) {
134134
})
135135
]
136136
}
137-
}
137+
};
138138
```
139139

140140
With the above webpack config, we see three bundles being generated. `vendor`, `main` and `manifest` bundles.

0 commit comments

Comments
 (0)