From 83b9e55d6e0994adb20fb6623bad9329f96b7d66 Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Fri, 11 Dec 2020 10:51:12 +0100 Subject: [PATCH] =?UTF-8?q?Ajoute=20une=20version=20CDN=20de=20la=20lib=20?= =?UTF-8?q?(avec=20toutes=20les=20d=C3=A9pendances,=20pour=20utiliser=20di?= =?UTF-8?q?rectement=20dans=20le=20navigateur)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #1211 --- modele-social/package.json | 1 + publicodes/package.json | 1 + publicodes/webpack.config.js | 20 +++++++++++++++----- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/modele-social/package.json b/modele-social/package.json index 5db9ab994..b81fc57fa 100644 --- a/modele-social/package.json +++ b/modele-social/package.json @@ -25,6 +25,7 @@ }, "scripts": { "build": "node build.js", + "clean": "rimraf dist node_modules", "prepare": "yarn run build", "up": "yarn version --minor && echo \"ℹ N'oubliez pas de poussez le tag git\"", "test": "echo 1" diff --git a/publicodes/package.json b/publicodes/package.json index 8b4149f8e..31beebe85 100644 --- a/publicodes/package.json +++ b/publicodes/package.json @@ -20,6 +20,7 @@ "dist/index.js", "dist/types", "dist/images", + "dist/publicodes.min.js", "esm" ], "private": false, diff --git a/publicodes/webpack.config.js b/publicodes/webpack.config.js index 284c37dea..eecdbcf84 100644 --- a/publicodes/webpack.config.js +++ b/publicodes/webpack.config.js @@ -7,17 +7,15 @@ const common = { resolve: { extensions: ['.ts', '.tsx', '.js'], }, - mode: 'development', + mode: process.env.NODE_ENV, entry: path.resolve(__dirname, 'source', 'index.ts'), module: { rules: commonLoaders({ file: false }), }, - externals: - // Every non-relative module is external - /^[a-z\-0-9]+$/, + } -module.exports = +module.exports = [ // Config for UMD export (browser / node) { ...common, @@ -27,4 +25,16 @@ module.exports = libraryTarget: 'umd', globalObject: 'this', }, + externals: + // Every non-relative module is external + /^[a-z\-0-9]+$/, + }, + process.env.NODE_ENV === 'production' && { + ...common, + output: { + filename: 'publicodes.min.js', + library: 'publicodes', + libraryTarget: 'global', + }, } +].filter(Boolean) \ No newline at end of file