Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/content/concepts/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ T> The most important part to take away from this document is that there are man

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

## The Simplest Configuration
## Simple Configuration

**webpack.config.js**

```javascript
var path = require('path');

module.exports = {
mode: 'development',
entry: './foo.js',
output: {
path: path.resolve(__dirname, 'dist'),
Expand Down
4 changes: 3 additions & 1 deletion src/content/configuration/configuration-languages.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import * as webpack from 'webpack';
import * as path from 'path';

const config: webpack.Configuration = {
mode: 'production',
entry: './foo.js',
output: {
path: path.resolve(__dirname, 'dist'),
Expand Down Expand Up @@ -101,6 +102,7 @@ webpack = require('webpack')
path = require('path')

config =
mode: 'production'
entry: './path/to/my/entry/file.js'
output:
path: path.resolve(__dirname, 'dist')
Expand Down Expand Up @@ -150,7 +152,7 @@ const CustomPlugin = config => ({
});

export default (
<webpack target="web" watch>
<webpack target="web" watch mode="production">
<entry path="src/index.js" />
<resolve>
<alias {...{
Expand Down
3 changes: 3 additions & 0 deletions src/content/configuration/configuration-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ One option is to export a function from your webpack config instead of exporting
-module.exports = {
+module.exports = function(env, argv) {
+ return {
+ mode: env.production ? 'production' : 'development',
+ devtool: env.production ? 'source-maps' : 'eval',
plugins: [
new webpack.optimize.UglifyJsPlugin({
Expand Down Expand Up @@ -64,11 +65,13 @@ module.exports = [{
libraryTarget: 'amd'
},
entry: './app.js',
mode: 'production',
}, {
output: {
filename: './dist-commonjs.js',
libraryTarget: 'commonjs'
},
entry: './app.js',
mode: 'production',
}]
```
7 changes: 7 additions & 0 deletions src/content/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ __webpack.config.js__
const path = require('path');

module.exports = {
<details><summary>[mode](/concepts/mode): "production", // "production" | "development" | "none"</summary>
[mode](/concepts/mode): "production", // enable many optimizations for production builds
[mode](/concepts/mode): "development", // enabled useful tools for development
[mode](/concepts/mode): "none", // no defaults
</details>
// Chosen mode tells webpack to use its built-in optimizations accordingly.

<details><summary>[entry](/configuration/entry-context#entry): "./app/entry", // string | object | array</summary>
[entry](/configuration/entry-context#entry): ["./app/entry1", "./app/entry2"],
[entry](/configuration/entry-context#entry): {
Expand Down