Skip to content

Commit

Permalink
chore: upgrade webpack, optimize, build
Browse files Browse the repository at this point in the history
  • Loading branch information
tabrindle committed Nov 6, 2018
1 parent 4543a06 commit 2a4590a
Show file tree
Hide file tree
Showing 7 changed files with 353 additions and 156 deletions.
2 changes: 1 addition & 1 deletion dist/cli.js
100755 → 100644

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/envinfo.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@
"os-name": "^2.0.1",
"pkg": "^4.3.4",
"prettier-eslint-cli": "^4.1.1",
"uglifyjs-webpack-plugin": "^1.2.1",
"webpack": "^4.5.0",
"webpack": "^4.25.1",
"webpack-cli": "^2.0.14",
"which": "^1.2.14",
"yamlify-object": "^0.4.5"
Expand Down
6 changes: 3 additions & 3 deletions src/cli.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const packageJson = require('../package.json');
const envinfo = require('./envinfo.js');
const argv = require('minimist')(process.argv.slice(2));
const version = __VERSION__ || ''; // eslint-disable-line

argv.console = true;

Expand All @@ -18,7 +18,7 @@ if (argv.help || argv._.indexOf('help') > -1) {
,,, ,,,
,,,' ',,,
VERSION: ${packageJson.version}
VERSION: ${version}
USAGE:
Expand Down Expand Up @@ -47,7 +47,7 @@ if (argv.help || argv._.indexOf('help') > -1) {
`);
process.exit(0);
} else if (argv.version || argv.v || argv._.indexOf('version') > -1) {
console.log(packageJson.version);
console.log(version); // eslint-disable-line no-console
process.exit(0);
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const run = cmd => {
const log = function log(level) {
const args = Object.values(Array.prototype.slice.call(arguments).slice(1));
if ((process.env.ENVINFO_DEBUG || '').toLowerCase() === level)
console.log(level, JSON.stringify(args));
console.log(level, JSON.stringify(args)); // eslint-disable-line no-console
};

const fileExists = filePath => {
Expand Down
9 changes: 7 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require('path');
const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const packageJson = require('./package.json');

module.exports = {
entry: {
Expand All @@ -9,19 +9,24 @@ module.exports = {
},
target: 'node',
mode: 'production',
optimization: {
minimize: true,
},
output: {
libraryTarget: 'commonjs2',
filename: '[name].js',
path: path.join(__dirname, '/dist'),
},
plugins: [
new UglifyJSPlugin(),
new webpack.BannerPlugin({
banner: `#!/usr/bin/env node
"use strict"`,
raw: true,
include: 'cli',
}),
new webpack.DefinePlugin({
__VERSION__: JSON.stringify(packageJson.version),
}),
new webpack.IgnorePlugin(/spawn-sync/),
],
};
Loading

0 comments on commit 2a4590a

Please sign in to comment.