mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-18 15:00: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
|
coverage
|
||||||
demo/markdown-it.min.js
|
demo/markdown-it.min.js
|
||||||
demo/markdownlint-browser.min.js
|
demo/markdownlint-browser.min.js
|
||||||
demo/markdownlint-browser.min.js.LICENSE.txt
|
|
||||||
demo/markdownlint-rule-helpers-browser.*
|
demo/markdownlint-rule-helpers-browser.*
|
||||||
node_modules
|
node_modules
|
||||||
!test/node_modules
|
!test/node_modules
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,11 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const webpack = require("webpack");
|
const webpack = require("webpack");
|
||||||
|
const TerserPlugin = require("terser-webpack-plugin");
|
||||||
const nodeModulePrefixRe = /^node:/u;
|
const nodeModulePrefixRe = /^node:/u;
|
||||||
|
|
||||||
function config(options) {
|
function config(options) {
|
||||||
const { entry, filename, mode, packageJson } = options;
|
const { entry, filename, mode, optimization, packageJson } = options;
|
||||||
const { name, version, homepage, license } = packageJson;
|
const { name, version, homepage, license } = packageJson;
|
||||||
return {
|
return {
|
||||||
"devtool": false,
|
"devtool": false,
|
||||||
|
|
@ -32,6 +33,7 @@ function config(options) {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"name": name,
|
"name": name,
|
||||||
|
"optimization": optimization,
|
||||||
"output": {
|
"output": {
|
||||||
"filename": filename,
|
"filename": filename,
|
||||||
"library": name.replace(/(-\w)/g, (m) => m.slice(1).toUpperCase()),
|
"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 = [
|
module.exports = [
|
||||||
config({
|
config({
|
||||||
"entry": "../lib/markdownlint.js",
|
...entryLibrary,
|
||||||
"filename": "markdownlint-browser.js",
|
...modeDevelopment,
|
||||||
"mode": "development",
|
"filename": "markdownlint-browser.js"
|
||||||
"packageJson": require("../package.json")
|
|
||||||
}),
|
}),
|
||||||
config({
|
config({
|
||||||
"entry": "../lib/markdownlint.js",
|
...entryLibrary,
|
||||||
"filename": "markdownlint-browser.min.js",
|
...modeProduction,
|
||||||
"mode": "production",
|
"filename": "markdownlint-browser.min.js"
|
||||||
"packageJson": require("../package.json")
|
|
||||||
}),
|
}),
|
||||||
config({
|
config({
|
||||||
"entry": "../helpers/helpers.js",
|
...entryHelpers,
|
||||||
"filename": "markdownlint-rule-helpers-browser.js",
|
...modeDevelopment,
|
||||||
"mode": "development",
|
"filename": "markdownlint-rule-helpers-browser.js"
|
||||||
"packageJson": require("../helpers/package.json")
|
|
||||||
}),
|
}),
|
||||||
config({
|
config({
|
||||||
"entry": "../helpers/helpers.js",
|
...entryHelpers,
|
||||||
"filename": "markdownlint-rule-helpers-browser.min.js",
|
...modeProduction,
|
||||||
"mode": "production",
|
"filename": "markdownlint-rule-helpers-browser.min.js"
|
||||||
"packageJson": require("../helpers/package.json")
|
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@
|
||||||
"markdownlint-rule-helpers": "0.17.2",
|
"markdownlint-rule-helpers": "0.17.2",
|
||||||
"npm-run-all": "4.1.5",
|
"npm-run-all": "4.1.5",
|
||||||
"strip-json-comments": "5.0.0",
|
"strip-json-comments": "5.0.0",
|
||||||
|
"terser-webpack-plugin": "5.3.5",
|
||||||
"toml": "3.0.0",
|
"toml": "3.0.0",
|
||||||
"ts-loader": "9.3.1",
|
"ts-loader": "9.3.1",
|
||||||
"tv4": "1.3.0",
|
"tv4": "1.3.0",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue