mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 22:40:13 +01:00
Refactor webpack.config.js for better code sharing, use default options for TerserPlugin, restore copyright banner for minified scripts.
This commit is contained in:
parent
3cae6ae4e6
commit
8c622a9bac
3 changed files with 42 additions and 18 deletions
|
|
@ -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"
|
||||
})
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue