From c0b11c72181bf5be17f7144699a19cab1a4388a7 Mon Sep 17 00:00:00 2001 From: lesion Date: Fri, 19 Nov 2021 17:55:12 +0100 Subject: [PATCH] minor on webpack configuration and add build script --- package.json | 3 ++- webpack.config.js | 30 ++++++++++++++---------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 29bc309..8991da3 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "scripts": { "test": "npm run test:node && npm run test:browser", "test:node": "mocha", - "test:browser": "karma start --single-run --browsers ChromeHeadless,FirefoxHeadless karma.config.js" + "test:browser": "karma start --single-run --browsers ChromeHeadless,FirefoxHeadless karma.config.js", + "build": "webpack" }, "author": "", "license": "ISC", diff --git a/webpack.config.js b/webpack.config.js index 434466e..16701f7 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,17 +1,15 @@ -const path = require('path'); +const path = require('path') -module.exports = [] -for(let target of ['web', 'node']) { - var conf = { - name: target, - entry: './radiomanifest.js', - target: [target], - output: { - path: path.resolve(__dirname, 'dist'), - filename: 'radiomanifest-' + target + '.bundle.js', - clean: false, - }, - } - module.exports.push(conf) -} -console.log(module.exports) +module.exports = ['web', 'node'].map( + target => ({ + name: target, + mode: 'production', + entry: './radiomanifest.js', + target: [target], + output: { + path: path.resolve(__dirname, 'dist'), + filename: 'radiomanifest-' + target + '.bundle.js', + clean: false + } + }) +)