diff --git a/.gitignore b/.gitignore index 9b598cbc..7ce8c006 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ coverage demo/markdown-it.min.js demo/markdownlint-browser.min.js -demo/markdownlint-browser.min.js.LICENSE.txt demo/markdownlint-rule-helpers-browser.* node_modules !test/node_modules diff --git a/demo/webpack.config.js b/demo/webpack.config.js index a09e202e..9c09b122 100644 --- a/demo/webpack.config.js +++ b/demo/webpack.config.js @@ -3,10 +3,11 @@ "use strict"; const webpack = require("webpack"); +const TerserPlugin = require("terser-webpack-plugin"); const nodeModulePrefixRe = /^node:/u; function config(options) { - const { entry, filename, mode, packageJson } = options; + const { entry, filename, mode, optimization, packageJson } = options; const { name, version, homepage, license } = packageJson; return { "devtool": false, @@ -32,6 +33,7 @@ function config(options) { ] }, "name": name, + "optimization": optimization, "output": { "filename": filename, "library": name.replace(/(-\w)/g, (m) => m.slice(1).toUpperCase()), @@ -60,29 +62,51 @@ function config(options) { }; } +const modeDevelopment = { + "mode": "development" +}; +const modeProduction = { + "mode": "production", + "optimization": { + "minimizer": [ + new TerserPlugin({ + "extractComments": false, + "terserOptions": { + "compress": { + "passes": 2 + } + } + }) + ] + } +}; +const entryLibrary = { + "entry": "../lib/markdownlint.js", + "packageJson": require("../package.json") +}; +const entryHelpers = { + "entry": "../helpers/helpers.js", + "packageJson": require("../helpers/package.json") +}; module.exports = [ config({ - "entry": "../lib/markdownlint.js", - "filename": "markdownlint-browser.js", - "mode": "development", - "packageJson": require("../package.json") + ...entryLibrary, + ...modeDevelopment, + "filename": "markdownlint-browser.js" }), config({ - "entry": "../lib/markdownlint.js", - "filename": "markdownlint-browser.min.js", - "mode": "production", - "packageJson": require("../package.json") + ...entryLibrary, + ...modeProduction, + "filename": "markdownlint-browser.min.js" }), config({ - "entry": "../helpers/helpers.js", - "filename": "markdownlint-rule-helpers-browser.js", - "mode": "development", - "packageJson": require("../helpers/package.json") + ...entryHelpers, + ...modeDevelopment, + "filename": "markdownlint-rule-helpers-browser.js" }), config({ - "entry": "../helpers/helpers.js", - "filename": "markdownlint-rule-helpers-browser.min.js", - "mode": "production", - "packageJson": require("../helpers/package.json") + ...entryHelpers, + ...modeProduction, + "filename": "markdownlint-rule-helpers-browser.min.js" }) ]; diff --git a/package.json b/package.json index ed6d3808..ede7f40f 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,7 @@ "markdownlint-rule-helpers": "0.17.2", "npm-run-all": "4.1.5", "strip-json-comments": "5.0.0", + "terser-webpack-plugin": "5.3.5", "toml": "3.0.0", "ts-loader": "9.3.1", "tv4": "1.3.0",