mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10: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
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
})
|
||||
];
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue