Skip to content

Commit 7b83c19

Browse files
author
Rajagopal
authored
Update production-build.md
1 parent 03d5128 commit 7b83c19

File tree

1 file changed

+36
-53
lines changed

1 file changed

+36
-53
lines changed

content/guides/production-build.md

Lines changed: 36 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -75,74 +75,57 @@ When we do have multiple configurations in mind for different environments, the
7575
each environment. For example:
7676
##config/dev.js
7777
```js
78-
module.exports = function(env) {
78+
module.exports = function (env) {
7979
debug: true,
8080
devtool: 'cheap-module-source-map',
8181
output: {
82-
path: path.join(__dirname, '/../dist/assets'),
83-
filename: '[name].bundle.js',
84-
publicPath: publicPath,
85-
sourceMapFilename: '[name].map'
82+
path: path.join(__dirname, '/../dist/assets'),
83+
filename: '[name].bundle.js',
84+
publicPath: publicPath,
85+
sourceMapFilename: '[name].map'
8686
},
8787
devServer: {
88-
port: 7777,
89-
host: 'localhost',
90-
historyApiFallback: true,
91-
noInfo: false,
92-
stats: 'minimal',
93-
publicPath: publicPath
94-
},
95-
});
88+
port: 7777,
89+
host: 'localhost',
90+
historyApiFallback: true,
91+
noInfo: false,
92+
stats: 'minimal',
93+
publicPath: publicPath
94+
}
95+
}
9696
```
9797
##config/prod.js
9898
```js
99-
module.exports = function(env) {
100-
debug: false,
99+
module.exports = function (env) {
100+
debug: false,
101101
output: {
102-
path: path.join(__dirname, '/../dist/assets'),
103-
filename: '[name].bundle.js',
104-
publicPath: publicPath,
105-
sourceMapFilename: '[name].map'
102+
path: path.join(__dirname, '/../dist/assets'),
103+
filename: '[name].bundle.js',
104+
publicPath: publicPath,
105+
sourceMapFilename: '[name].map'
106106
},
107107
plugins: [
108-
new webpack.LoaderOptionsPlugin({
109-
minimize: true,
110-
debug: false
111-
}),
112-
new UglifyJsPlugin({
113-
beautify: false,
114-
mangle: { screw_ie8 : true, keep_fnames: true },
115-
compress: { screw_ie8: true },
116-
comments: false
117-
})
108+
new webpack.LoaderOptionsPlugin({
109+
minimize: true,
110+
debug: false
111+
}),
112+
new UglifyJsPlugin({
113+
beautify: false,
114+
mangle: {
115+
screw_ie8: true,
116+
keep_fnames: true
117+
},
118+
compress: {
119+
screw_ie8: true
120+
},
121+
comments: false
122+
})
118123
]
119-
});
124+
}
120125
```
121126
Have our webpack.config.js has the following snippet:
122127
```js
123-
function buildConfig(env) {
124-
var config;
125-
switch (env) {
126-
case 'prod':
127-
config = require('./config/prod.js')({env: 'prod'});
128-
break;
129-
case 'qa':
130-
config = require('./config/qa.js')({env: 'qa'});
131-
break;
132-
case 'test':
133-
config = require('./config/test.js')({env: 'test'});
134-
break;
135-
case 'dev':
136-
config = require('./config/dev.js')({env: 'dev'});
137-
break;
138-
default:
139-
config = require('./config/dev.js')({env: 'dev'});
140-
break;
141-
}
142-
return config;
143-
}
144-
145-
module.exports = buildConfig(env);
128+
return require('./config/' + env + '.js')({ env: env })
146129
```
147130
And from our package.json, where we build our application using webpack, the command goes like this:
148131
```js

0 commit comments

Comments
 (0)