Skip to content

Commit 8ebfcaa

Browse files
author
Anthony Gore
committed
Adding webpack config print
1 parent 5963b94 commit 8ebfcaa

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ npm-debug.log
44
.idea
55
.env
66
dist
7+
tmp

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"license": "UNLICENSED",
1212
"scripts": {
1313
"start": "nodemon ./server.js --ignore src/ -e js,html,css",
14-
"build": "rimraf dist && cross-env NODE_ENV=production webpack --config webpack.config.js --progress --hide-modules"
14+
"build": "rimraf dist && cross-env NODE_ENV=production webpack --config webpack.config.js --progress --hide-modules",
15+
"webpack-config-output": "rimraf tmp && mkdir tmp && cross-env NODE_ENV=production node ./scripts/webpack-config-output.js && cross-env NODE_ENV=development node ./scripts/webpack-config-output.js"
1516
},
1617
"dependencies": {
1718
"body-parser": "^1.15.2",
@@ -37,6 +38,7 @@
3738
"css-loader": "^0.25.0",
3839
"extract-text-webpack-plugin": "^2.0.0-beta.5",
3940
"file-loader": "^0.9.0",
41+
"js-object-pretty-print": "^0.2.0",
4042
"node-sass": "^4.1.1",
4143
"open": "0.0.5",
4244
"sass-loader": "^4.1.1",

scripts/webpack-config-output.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var fs = require('fs');
2+
var pretty = require('js-object-pretty-print').pretty;
3+
4+
require('../webpack.config.js').forEach(target => {
5+
let fileName = `./tmp/${target.target}.${process.env.NODE_ENV === 'production' ? 'prod' : 'dev' }.js`;
6+
fs.writeFile(
7+
fileName,
8+
`module.export = ${pretty(target)};`,
9+
function(err) {
10+
if(err) {
11+
return console.log(err);
12+
}
13+
console.log(`${fileName} successfully saved.`);
14+
}
15+
);
16+
});
17+

0 commit comments

Comments
 (0)