From 6df01d553bd0673bae01ac37f137b8067b400aeb Mon Sep 17 00:00:00 2001 From: Justin Date: Wed, 30 Nov 2016 16:46:50 +0000 Subject: [PATCH] add version and license banner to packaged files --- package.json | 8 +++++--- webpack.config.js | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 webpack.config.js diff --git a/package.json b/package.json index 53e3f75..1a3c115 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,9 @@ "test:debug": "DEBUG=genscrape:* npm test", "coverage": "istanbul cover ./node_modules/mocha/bin/_mocha -- --recursive", "coveralls": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- --recursive && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage", - "build": "mkdir -p dist && npm run build:full && npm run build:min", - "build:full": "webpack --output-library genscrape src/main.js dist/genscrape.js", - "build:min": "webpack --output-library genscrape --optimize-minimize src/main.js dist/genscrape.min.js", + "build": "mkdir -p dist && npm run build:dev && npm run build:min", + "build:dev": "webpack", + "build:min": "webpack --min", "prepublish": "npm test && npm run build" }, "repository": { @@ -34,10 +34,12 @@ "gedcomx-js": "2.1.0" }, "devDependencies": { + "bannerjs": "^1.0.5", "chai": "3.5.0", "coveralls": "2.11.9", "istanbul": "0.4.3", "jsdom": "9.5.0", + "minimist": "^1.2.0", "mocha": "3.1.0", "nock": "8.0.0", "webpack": "^1.13.1" diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..b17781d --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,22 @@ +var bannerjs = require('bannerjs'), + webpack = require('webpack'), + argv = require('minimist')(process.argv); + +module.exports = { + entry: './src/main.js', + output: { + filename: 'genscrape.js', + path: __dirname + '/dist', + library: 'genscrape', + libraryTarget: 'umd' + }, + plugins: [ + new webpack.BannerPlugin(bannerjs.onebanner(), {raw: true}) + ] +}; + +// Add minification, enabled by a cli flag +if(argv.min){ + module.exports.plugins.push(new webpack.optimize.UglifyJsPlugin()); + module.exports.output.filename = 'genscrape.min.js'; +} \ No newline at end of file