Quellcode durchsuchen

Updates dependencies & lint rules

main
Eric Amodio vor 4 Jahren
Ursprung
Commit
18663a1650
16 geänderte Dateien mit 798 neuen und 731 gelöschten Zeilen
  1. +73
    -2
      .eslintrc.json
  2. +20
    -21
      package.json
  3. +1
    -1
      src/git/git.ts
  4. +0
    -1
      src/git/models/branch.ts
  5. +0
    -1
      src/git/models/repository.ts
  6. +14
    -6
      src/github/github.ts
  7. +4
    -4
      src/logger.ts
  8. +8
    -4
      src/messages.ts
  9. +2
    -2
      src/system/array.ts
  10. +1
    -1
      src/system/searchTree.ts
  11. +1
    -0
      src/system/string.ts
  12. +0
    -1
      src/views/compareView.ts
  13. +0
    -1
      src/views/nodes/compareBranchNode.ts
  14. +2
    -2
      src/views/viewBase.ts
  15. +118
    -64
      webpack.config.js
  16. +554
    -620
      yarn.lock

+ 73
- 2
.eslintrc.json Datei anzeigen

@ -7,7 +7,6 @@
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
@ -112,6 +111,7 @@
"newlines-between": "never"
}
],
"@typescript-eslint/ban-types": "off", // TODO@eamodio revisit
"@typescript-eslint/consistent-type-assertions": [
"error",
{
@ -121,17 +121,88 @@
],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/explicit-module-boundary-types": "off", // TODO@eamodio revisit
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "variable",
"format": ["camelCase", "PascalCase"],
"leadingUnderscore": "allow",
"filter": {
"regex": "^_$",
"match": false
}
},
{
"selector": "variableLike",
"format": ["camelCase"],
"leadingUnderscore": "allow",
"filter": {
"regex": "^_$",
"match": false
}
},
{
"selector": "memberLike",
"modifiers": ["private"],
"format": ["camelCase"],
"leadingUnderscore": "allow"
},
{
"selector": "memberLike",
"modifiers": ["private", "readonly"],
"format": ["camelCase", "PascalCase"],
"leadingUnderscore": "allow"
},
{
"selector": "memberLike",
"modifiers": ["static", "readonly"],
"format": ["camelCase", "PascalCase"]
},
{
"selector": "interface",
"format": ["PascalCase"],
"custom": {
"regex": "^I[A-Z]",
"match": false
}
}
],
"@typescript-eslint/no-empty-function": ["warn", { "allow": ["constructors"] }],
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-floating-promises": "off", // TODO@eamodio revisit
"@typescript-eslint/no-inferrable-types": ["warn", { "ignoreParameters": true, "ignoreProperties": true }],
"@typescript-eslint/no-misused-promises": ["error", { "checksVoidReturn": false }],
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-parameter-properties": "off",
"@typescript-eslint/no-unnecessary-condition": "off",
"@typescript-eslint/no-unsafe-assignment": "off", // TODO@eamodio revisit
"@typescript-eslint/no-unsafe-call": "off", // TODO@eamodio revisit
"@typescript-eslint/no-unsafe-member-access": "off", // TODO@eamodio revisit
"@typescript-eslint/no-unsafe-return": "off", // TODO@eamodio revisit
"@typescript-eslint/no-unused-expressions": ["warn", { "allowShortCircuit": true }],
"@typescript-eslint/no-unused-vars": ["warn", { "args": "none" }],
"@typescript-eslint/no-unused-vars": [
"warn",
{
"args": "after-used",
"argsIgnorePattern": "^_",
"ignoreRestSiblings": true,
"varsIgnorePattern": "^_$"
}
],
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/prefer-nullish-coalescing": "warn",
"@typescript-eslint/prefer-optional-chain": "warn",
"@typescript-eslint/restrict-template-expressions": [
"error",
{ "allowAny": true, "allowBoolean": true, "allowNumber": true, "allowNullish": true }
],
"@typescript-eslint/strict-boolean-expressions": [
"warn",
{ "allowNullableBoolean": true, "allowNullableNumber": true, "allowNullableString": true }
],
"@typescript-eslint/unbound-method": "off" // Too many bugs right now: https://github.com/typescript-eslint/typescript-eslint/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+unbound-method
}
}

+ 20
- 21
package.json Datei anzeigen

@ -18,7 +18,7 @@
"url": "https://github.com/eamodio/vscode-gitlens.git"
},
"engines": {
"vscode": "^1.44.0"
"vscode": "^1.45.1"
},
"main": "./dist/extension",
"icon": "images/gitlens-icon.png",
@ -6157,8 +6157,8 @@
"scripts": {
"analyze:bundle": "webpack --env.analyzeBundle",
"analyze:deps": "webpack --env.analyzeDeps",
"build": "webpack --env.development",
"bundle": "webpack --env.production",
"build": "webpack --mode development",
"bundle": "webpack --mode production",
"clean": "git clean -Xdf -e !node_modules -e !node_modules/**/*",
"lint": "eslint src/**/*.ts --fix",
"pack": "vsce package --yarn",
@ -6166,15 +6166,15 @@
"pub": "vsce publish --yarn",
"rebuild": "yarn run reset && yarn run build",
"reset": "yarn run clean && yarn --frozen-lockfile",
"watch": "webpack --watch --env.development --info-verbosity verbose",
"watch": "webpack --watch --mode development --info-verbosity verbose",
"webviews:optimize": "webpack --config-name webviews --env.optimizeImages",
"webviews:watch": "webpack --watch --config-name webviews --env.development --info-verbosity verbose",
"webviews:watch": "webpack --watch --config-name webviews --mode development --info-verbosity verbose",
"update:emoji": "pushd emoji && node ./shortcodeToEmoji.js && popd",
"vscode:prepublish": "yarn run bundle"
},
"dependencies": {
"@octokit/graphql": "4.3.1",
"dayjs": "1.8.25",
"@octokit/graphql": "4.5.0",
"dayjs": "1.8.27",
"iconv-lite": "0.5.1",
"lodash-es": "4.17.15",
"vsls": "1.0.1830"
@ -6182,33 +6182,32 @@
"devDependencies": {
"@types/keytar": "4.4.2",
"@types/lodash-es": "4.17.3",
"@types/node": "12.12.37",
"@types/vscode": "1.44.0",
"@typescript-eslint/eslint-plugin": "2.30.0",
"@typescript-eslint/parser": "2.30.0",
"@types/node": "12.12.42",
"@types/vscode": "1.45.1",
"@typescript-eslint/eslint-plugin": "3.0.0",
"@typescript-eslint/parser": "3.0.0",
"circular-dependency-plugin": "5.2.0",
"clean-webpack-plugin": "3.0.0",
"csp-html-webpack-plugin": "4.0.0",
"css-loader": "3.5.3",
"eslint": "6.8.0",
"eslint": "7.1.0",
"eslint-cli": "1.1.1",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-import": "2.20.2",
"fork-ts-checker-webpack-plugin": "4.1.3",
"html-webpack-exclude-assets-plugin": "0.0.7",
"html-webpack-inline-source-plugin": "0.0.10",
"html-webpack-plugin": "3.2.0",
"fork-ts-checker-webpack-plugin": "4.1.4",
"html-webpack-plugin": "4.3.0",
"html-webpack-skip-assets-plugin": "0.0.2",
"imagemin-webpack-plugin": "2.4.2",
"mini-css-extract-plugin": "0.9.0",
"node-sass": "4.14.0",
"node-sass": "4.14.1",
"prettier": "2.0.5",
"sass-loader": "8.0.2",
"terser-webpack-plugin": "2.3.6",
"ts-loader": "7.0.1",
"typescript": "3.9.1-rc",
"terser-webpack-plugin": "3.0.1",
"ts-loader": "7.0.4",
"typescript": "3.9.3",
"vsce": "1.75.0",
"webpack": "4.43.0",
"webpack-bundle-analyzer": "3.7.0",
"webpack-bundle-analyzer": "3.8.0",
"webpack-cli": "3.3.11"
}
}

+ 1
- 1
src/git/git.ts Datei anzeigen

@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/naming-convention */
'use strict';
/* eslint-disable @typescript-eslint/camelcase */
import * as paths from 'path';
import * as iconv from 'iconv-lite';
import { GlyphChars } from '../constants';

+ 0
- 1
src/git/models/branch.ts Datei anzeigen

@ -199,7 +199,6 @@ export class GitBranch implements GitReference {
if (star) {
starred![this.id] = true;
} else {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { [this.id]: _, ...rest } = starred!;
starred = rest;
}

+ 0
- 1
src/git/models/repository.ts Datei anzeigen

@ -574,7 +574,6 @@ export class Repository implements Disposable {
if (star) {
starred![this.id] = true;
} else {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { [this.id]: _, ...rest } = starred!;
starred = rest;
}

+ 14
- 6
src/github/github.ts Datei anzeigen

@ -7,7 +7,7 @@ import { IssueOrPullRequest, PullRequest, PullRequestState } from '../git/gitSer
export class GitHubApi {
@debug({
args: {
1: token => '<token>',
1: _ => '<token>',
},
})
async getPullRequestForCommit(
@ -51,12 +51,20 @@ export class GitHubApi {
const variables = { owner: owner, repo: repo, sha: ref };
// Logger.debug(cc, `variables: ${JSON.stringify(variables)}`);
const rsp = await graphql(query, {
const rsp = await graphql<{
repository?: {
object?: {
associatedPullRequests?: {
nodes?: GitHubPullRequest[];
};
};
};
}>(query, {
...variables,
headers: { authorization: `token ${token}` },
...options,
});
const pr = rsp?.repository?.object?.associatedPullRequests?.nodes?.[0] as GitHubPullRequest | undefined;
const pr = rsp?.repository?.object?.associatedPullRequests?.nodes?.[0];
if (pr == null) return undefined;
// GitHub seems to sometimes return PRs for forks
if (pr.repository.owner.login !== owner) return undefined;
@ -83,7 +91,7 @@ export class GitHubApi {
@debug({
args: {
1: token => '<token>',
1: _ => '<token>',
},
})
async getIssueOrPullRequest(
@ -122,12 +130,12 @@ export class GitHubApi {
const variables = { owner: owner, repo: repo, number: number };
// Logger.debug(cc, `variables: ${JSON.stringify(variables)}`);
const rsp = await graphql(query, {
const rsp = await graphql<{ repository?: { issueOrPullRequest?: GitHubIssueOrPullRequest } }>(query, {
...variables,
headers: { authorization: `token ${token}` },
...options,
});
const issue = rsp?.repository?.issueOrPullRequest as GitHubIssueOrPullRequest | undefined;
const issue = rsp?.repository?.issueOrPullRequest;
if (issue == null) return undefined;
return {

+ 4
- 4
src/logger.ts Datei anzeigen

@ -102,7 +102,7 @@ export class Logger {
if (this.output !== undefined && this.level !== TraceLevel.Silent) {
this.output.appendLine(
`${this.timestamp} ${message || emptyStr}${this.toLoggableParams(false, params)}\n${ex}`,
`${this.timestamp} ${message || emptyStr}${this.toLoggableParams(false, params)}\n${ex?.toString()}`,
);
}
@ -222,15 +222,15 @@ export class Logger {
}
static toLoggableName(instance: Function | object) {
let name;
let name: string;
if (typeof instance === 'function') {
if (instance.prototype == null || instance.prototype.constructor == null) {
return instance.name;
}
name = instance.prototype.constructor.name;
name = instance.prototype.constructor.name ?? emptyStr;
} else {
name = instance.constructor != null ? instance.constructor.name : emptyStr;
name = instance.constructor?.name ?? emptyStr;
}
// Strip webpack module name (since I never name classes with an _)

+ 8
- 4
src/messages.ts Datei anzeigen

@ -150,10 +150,12 @@ export class Messages {
dontShowAgain: MessageItem | null = { title: "Don't Show Again" },
...actions: MessageItem[]
): Promise<MessageItem | undefined> {
Logger.log(`ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain})`);
Logger.log(`ShowMessage(${type}, '${message}', ${suppressionKey}, ${JSON.stringify(dontShowAgain)})`);
if (suppressionKey !== undefined && configuration.get('advanced', 'messages', suppressionKey)) {
Logger.log(`ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain}) skipped`);
Logger.log(
`ShowMessage(${type}, '${message}', ${suppressionKey}, ${JSON.stringify(dontShowAgain)}) skipped`,
);
return undefined;
}
@ -178,7 +180,9 @@ export class Messages {
if ((suppressionKey !== undefined && dontShowAgain === null) || result === dontShowAgain) {
Logger.log(
`ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain}) don't show again requested`,
`ShowMessage(${type}, '${message}', ${suppressionKey}, ${JSON.stringify(
dontShowAgain,
)}) don't show again requested`,
);
await this.suppressedMessage(suppressionKey!);
@ -186,7 +190,7 @@ export class Messages {
}
Logger.log(
`ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain}) returned ${
`ShowMessage(${type}, '${message}', ${suppressionKey}, ${JSON.stringify(dontShowAgain)}) returned ${
result ? result.title : result
}`,
);

+ 2
- 2
src/system/array.ts Datei anzeigen

@ -8,10 +8,10 @@ import {
export namespace Arrays {
export function countUniques<T>(source: T[], accessor: (item: T) => string): { [key: string]: number } {
const uniqueCounts = Object.create(null);
const uniqueCounts: Record<string, number> = Object.create(null);
for (const item of source) {
const value = accessor(item);
uniqueCounts[value] = (uniqueCounts[value] || 0) + 1;
uniqueCounts[value] = (uniqueCounts[value] ?? 0) + 1;
}
return uniqueCounts;
}

+ 1
- 1
src/system/searchTree.ts Datei anzeigen

@ -6,7 +6,7 @@ import { Strings } from './string';
const FIN = { done: true, value: undefined };
// eslint-disable-next-line @typescript-eslint/interface-name-prefix
// eslint-disable-next-line @typescript-eslint/naming-convention
export interface IKeyIterator {
reset(key: string): this;
next(): this;

+ 1
- 0
src/system/string.ts Datei anzeigen

@ -110,6 +110,7 @@ export namespace Strings {
let fn = interpolationMap.get(template);
if (fn === undefined) {
// eslint-disable-next-line @typescript-eslint/no-implied-eval
fn = new Function(`return \`${template.replace(tokenSanitizeRegex, tokenSanitizeReplacement)}\`;`);
interpolationMap.set(template, fn);
}

+ 0
- 1
src/views/compareView.ts Datei anzeigen

@ -155,7 +155,6 @@ export class CompareView extends ViewBase {
if (pin !== undefined) {
pinned![id] = { ...pin };
} else {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { [id]: _, ...rest } = pinned!;
pinned = rest;
}

+ 0
- 1
src/views/nodes/compareBranchNode.ts Datei anzeigen

@ -249,7 +249,6 @@ export class CompareBranchNode extends ViewNode {
if (compareWith) {
comparisons![this.branch.id] = { ...compareWith };
} else {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { [this.branch.id]: _, ...rest } = comparisons!;
comparisons = rest;
}

+ 2
- 2
src/views/viewBase.ts Datei anzeigen

@ -35,8 +35,8 @@ export interface TreeViewNodeStateChangeEvent extends TreeViewExpansionEvent<
}
export abstract class ViewBase<TRoot extends ViewNode<View>> implements TreeDataProvider<ViewNode>, Disposable {
protected _onDidChangeTreeData = new EventEmitter<ViewNode>();
get onDidChangeTreeData(): Event<ViewNode> {
protected _onDidChangeTreeData = new EventEmitter<ViewNode | undefined>();
get onDidChangeTreeData(): Event<ViewNode | undefined> {
return this._onDidChangeTreeData.event;
}

+ 118
- 64
webpack.config.js Datei anzeigen

@ -1,5 +1,8 @@
'use strict';
// @ts-check
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
/* eslint-disable @typescript-eslint/strict-boolean-expressions */
'use strict';
const fs = require('fs');
const path = require('path');
const glob = require('glob');
@ -7,43 +10,97 @@ const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPl
const { CleanWebpackPlugin: CleanPlugin } = require('clean-webpack-plugin');
const CircularDependencyPlugin = require('circular-dependency-plugin');
const CspHtmlPlugin = require('csp-html-webpack-plugin');
// const ESLintPlugin = require('eslint-webpack-plugin');
const ForkTsCheckerPlugin = require('fork-ts-checker-webpack-plugin');
const HtmlExcludeAssetsPlugin = require('html-webpack-exclude-assets-plugin');
const HtmlInlineSourcePlugin = require('html-webpack-inline-source-plugin');
const HtmlPlugin = require('html-webpack-plugin');
const HtmlSkipAssetsPlugin = require('html-webpack-skip-assets-plugin').HtmlWebpackSkipAssetsPlugin;
const ImageminPlugin = require('imagemin-webpack-plugin').default;
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');
module.exports = function (env, argv) {
env = env || {};
env.analyzeBundle = Boolean(env.analyzeBundle);
env.analyzeDeps = Boolean(env.analyzeDeps);
env.production = env.analyzeBundle || Boolean(env.production);
env.optimizeImages = Boolean(env.optimizeImages) || (env.production && !env.analyzeBundle);
class InlineChunkHtmlPlugin {
constructor(htmlPlugin, patterns) {
this.htmlPlugin = htmlPlugin;
this.patterns = patterns;
}
getInlinedTag(publicPath, assets, tag) {
if (
(tag.tagName !== 'script' || !(tag.attributes && tag.attributes.src)) &&
(tag.tagName !== 'link' || !(tag.attributes && tag.attributes.href))
) {
return tag;
}
let chunkName = tag.tagName === 'link' ? tag.attributes.href : tag.attributes.src;
if (publicPath) {
chunkName = chunkName.replace(publicPath, '');
}
if (!this.patterns.some(pattern => chunkName.match(pattern))) {
return tag;
}
const asset = assets[chunkName];
if (asset == null) {
return tag;
}
return { tagName: tag.tagName === 'link' ? 'style' : tag.tagName, innerHTML: asset.source(), closeTag: true };
}
apply(compiler) {
let publicPath = compiler.options.output.publicPath || '';
if (publicPath && !publicPath.endsWith('/')) {
publicPath += '/';
}
if (!env.optimizeImages && !fs.existsSync(path.resolve(__dirname, 'images/settings'))) {
env.optimizeImages = true;
compiler.hooks.compilation.tap('InlineChunkHtmlPlugin', compilation => {
const getInlinedTagFn = tag => this.getInlinedTag(publicPath, compilation.assets, tag);
this.htmlPlugin.getHooks(compilation).alterAssetTagGroups.tap('InlineChunkHtmlPlugin', assets => {
assets.headTags = assets.headTags.map(getInlinedTagFn);
assets.bodyTags = assets.bodyTags.map(getInlinedTagFn);
});
});
}
}
module.exports =
/**
* @param {{ analyzeBundle?: boolean; analyzeDeps?: boolean; optimizeImages?: boolean; } | undefined } env
* @param {{ mode: 'production' | 'development' | 'none' | undefined; }} argv
*/
function (env, argv) {
const mode = argv.mode || 'none';
return [getExtensionConfig(env), getWebviewsConfig(env)];
};
env = {
analyzeBundle: false,
analyzeDeps: false,
optimizeImages: mode === 'production',
...env,
};
function getExtensionConfig(env) {
if (env.analyzeBundle || env.analyzeDeps) {
env.optimizeImages = false;
} else if (!env.optimizeImages && !fs.existsSync(path.resolve(__dirname, 'images/settings'))) {
env.optimizeImages = true;
}
return [getExtensionConfig(mode, env), getWebviewsConfig(mode, env)];
};
/**
* @param { 'production' | 'development' | 'none' } mode
* @param {{ analyzeBundle?: boolean; analyzeDeps?: boolean; optimizeImages?: boolean; }} env
*/
function getExtensionConfig(mode, env) {
/**
* @type any[]
*/
const plugins = [
new CleanPlugin({ cleanOnceBeforeBuildPatterns: ['**/*', '!**/webviews/**'] }),
// new ESLintPlugin({
// context: path.resolve(__dirname, 'src'),
// files: '**/*.ts',
// lintDirtyModulesOnly: true
// })
new ForkTsCheckerPlugin({
async: false,
eslint: true,
eslint: true, // { files: './src/**/*.ts' },
useTypescriptIncrementalApi: true,
}),
];
@ -54,7 +111,7 @@ function getExtensionConfig(env) {
cwd: __dirname,
exclude: /node_modules/,
failOnError: false,
onDetected: function ({ module: webpackModuleRecord, paths, compilation }) {
onDetected: function ({ module: _webpackModuleRecord, paths, compilation }) {
if (paths.some(p => p.includes('container.ts'))) return;
compilation.warnings.push(new Error(paths.join(' -> ')));
@ -70,7 +127,7 @@ function getExtensionConfig(env) {
return {
name: 'extension',
entry: './src/extension.ts',
mode: env.production ? 'production' : 'development',
mode: mode,
target: 'node',
node: {
__dirname: false,
@ -90,7 +147,6 @@ function getExtensionConfig(env) {
terserOptions: {
ecma: 8,
// Keep the class names otherwise @log won't provide a useful name
// eslint-disable-next-line @typescript-eslint/camelcase
keep_classnames: true,
module: true,
},
@ -142,7 +198,11 @@ function getExtensionConfig(env) {
};
}
function getWebviewsConfig(env) {
/**
* @param { 'production' | 'development' | 'none' } mode
* @param {{ analyzeBundle?: boolean; analyzeDeps?: boolean; optimizeImages?: boolean; }} env
*/
function getWebviewsConfig(mode, env) {
const clean = ['**/*'];
if (env.optimizeImages) {
console.log('Optimizing images (src/webviews/apps/images/settings/*.png)...');
@ -156,7 +216,7 @@ function getWebviewsConfig(env) {
'style-src': ['vscode-resource:'],
};
if (!env.production) {
if (mode === 'production') {
cspPolicy['script-src'].push("'unsafe-eval'");
}
@ -165,16 +225,10 @@ function getWebviewsConfig(env) {
*/
const plugins = [
new CleanPlugin({ cleanOnceBeforeBuildPatterns: clean }),
// new ESLintPlugin({
// context: path.resolve(__dirname, 'src/webviews/apps'),
// files: '**/*.ts',
// lintDirtyModulesOnly: true
// }),
new ForkTsCheckerPlugin({
tsconfig: path.resolve(__dirname, 'tsconfig.webviews.json'),
async: false,
eslint: true,
useTypescriptIncrementalApi: true,
eslint: true, // { files: './src/**/*.ts' },
}),
new MiniCssExtractPlugin({
filename: '[name].css',
@ -185,7 +239,6 @@ function getWebviewsConfig(env) {
template: 'settings/index.html',
filename: path.resolve(__dirname, 'dist/webviews/settings.html'),
inject: true,
inlineSource: env.production ? '.css$' : undefined,
cspPlugin: {
enabled: true,
policy: cspPolicy,
@ -194,18 +247,19 @@ function getWebviewsConfig(env) {
'style-src': true,
},
},
minify: env.production
? {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: false,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyCSS: true,
}
: false,
minify:
mode === 'production'
? {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: false,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyCSS: true,
}
: false,
}),
new HtmlPlugin({
excludeAssets: [/.+-styles\.js/],
@ -213,7 +267,6 @@ function getWebviewsConfig(env) {
template: 'welcome/index.html',
filename: path.resolve(__dirname, 'dist/webviews/welcome.html'),
inject: true,
inlineSource: env.production ? '.css$' : undefined,
cspPlugin: {
enabled: true,
policy: cspPolicy,
@ -222,20 +275,21 @@ function getWebviewsConfig(env) {
'style-src': true,
},
},
minify: env.production
? {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: false,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyCSS: true,
}
: false,
minify:
mode === 'production'
? {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: false,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyCSS: true,
}
: false,
}),
new HtmlExcludeAssetsPlugin(),
new HtmlSkipAssetsPlugin({}),
new CspHtmlPlugin(),
new ImageminPlugin({
disable: !env.optimizeImages,
@ -250,11 +304,11 @@ function getWebviewsConfig(env) {
optipng: null,
pngquant: {
quality: '85-100',
speed: env.production ? 1 : 10,
speed: mode === 'production' ? 1 : 10,
},
svgo: null,
}),
new HtmlInlineSourcePlugin(),
new InlineChunkHtmlPlugin(HtmlPlugin, mode === 'production' ? ['\\.css$'] : []),
];
return {
@ -265,8 +319,8 @@ function getWebviewsConfig(env) {
settings: ['./settings/index.ts'],
welcome: ['./welcome/index.ts'],
},
mode: env.production ? 'production' : 'development',
devtool: env.production ? undefined : 'eval-source-map',
mode: mode,
devtool: mode === 'production' ? undefined : 'eval-source-map',
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist/webviews'),

+ 554
- 620
yarn.lock
Datei-Diff unterdrückt, da er zu groß ist
Datei anzeigen


Laden…
Abbrechen
Speichern