@simplysm/sd-cli 6.4.5 → 7.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +11 -0
- package/dist/bin/sd-cli.d.ts +1 -0
- package/dist/bin/sd-cli.mjs +86 -0
- package/dist/build-tool/SdCliCacheCompilerHost.d.ts +10 -0
- package/dist/build-tool/SdCliCacheCompilerHost.mjs +44 -0
- package/dist/build-tool/SdCliNgCacheCompilerHost.d.ts +11 -0
- package/dist/build-tool/SdCliNgCacheCompilerHost.mjs +36 -0
- package/dist/build-tool/SdCliPackageLinter.d.ts +8 -0
- package/dist/build-tool/SdCliPackageLinter.mjs +41 -0
- package/dist/builder/SdCliJsLibBuilder.d.ts +14 -0
- package/dist/builder/SdCliJsLibBuilder.mjs +50 -0
- package/dist/builder/SdCliTsLibBuilder.d.ts +27 -0
- package/dist/builder/SdCliTsLibBuilder.mjs +226 -0
- package/dist/commons.d.ts +46 -0
- package/dist/commons.mjs +2 -0
- package/dist/entry-points/SdCliWorkspace.d.ts +18 -0
- package/dist/entry-points/SdCliWorkspace.mjs +193 -0
- package/dist/packages/SdCliPackage.d.ts +19 -0
- package/dist/packages/SdCliPackage.mjs +89 -0
- package/dist/utils/SdCliBuildResultUtil.d.ts +6 -0
- package/dist/utils/SdCliBuildResultUtil.mjs +38 -0
- package/dist/utils/SdCliConfigUtil.d.ts +7 -0
- package/dist/utils/SdCliConfigUtil.mjs +69 -0
- package/lib/ts-node-esm-paths.mjs +15 -0
- package/package.json +27 -59
- package/src/bin/sd-cli.ts +86 -214
- package/src/build-tool/SdCliCacheCompilerHost.ts +71 -0
- package/src/build-tool/SdCliNgCacheCompilerHost.ts +50 -0
- package/src/build-tool/SdCliPackageLinter.ts +54 -0
- package/src/builder/SdCliJsLibBuilder.ts +66 -0
- package/src/builder/SdCliTsLibBuilder.ts +335 -0
- package/src/commons.ts +17 -122
- package/src/entry-points/SdCliWorkspace.ts +229 -0
- package/src/packages/SdCliPackage.ts +111 -0
- package/src/utils/SdCliBuildResultUtil.ts +43 -0
- package/src/utils/SdCliConfigUtil.ts +94 -0
- package/tsconfig-build.json +9 -0
- package/tsconfig.json +7 -18
- package/.eslintrc.js +0 -19
- package/dist-node/bin/sd-cli.js +0 -197
- package/dist-node/bin/sd-cli.js.map +0 -1
- package/dist-node/build-tools/SdCliCordova.js +0 -144
- package/dist-node/build-tools/SdCliCordova.js.map +0 -1
- package/dist-node/build-tools/SdCliIndexFileGenerator.js +0 -51
- package/dist-node/build-tools/SdCliIndexFileGenerator.js.map +0 -1
- package/dist-node/build-tools/SdCliNgModuleFilesGenerator.js +0 -675
- package/dist-node/build-tools/SdCliNgModuleFilesGenerator.js.map +0 -1
- package/dist-node/build-tools/metadata/SdAotMetadataReader.js +0 -274
- package/dist-node/build-tools/metadata/SdAotMetadataReader.js.map +0 -1
- package/dist-node/build-tools/metadata/SdIvyMetadataReader.js +0 -124
- package/dist-node/build-tools/metadata/SdIvyMetadataReader.js.map +0 -1
- package/dist-node/build-tools/metadata/SdMetadataError.js +0 -13
- package/dist-node/build-tools/metadata/SdMetadataError.js.map +0 -1
- package/dist-node/build-tools/metadata/SdMyMetadataReader.js +0 -321
- package/dist-node/build-tools/metadata/SdMyMetadataReader.js.map +0 -1
- package/dist-node/builders/SdCliJavascriptLinter.js +0 -65
- package/dist-node/builders/SdCliJavascriptLinter.js.map +0 -1
- package/dist-node/builders/SdCliNgClientBuilder.js +0 -636
- package/dist-node/builders/SdCliNgClientBuilder.js.map +0 -1
- package/dist-node/builders/SdCliNgLibraryBuilder.js +0 -217
- package/dist-node/builders/SdCliNgLibraryBuilder.js.map +0 -1
- package/dist-node/builders/SdCliPublisher.js +0 -129
- package/dist-node/builders/SdCliPublisher.js.map +0 -1
- package/dist-node/builders/SdCliServerBuilder.js +0 -452
- package/dist-node/builders/SdCliServerBuilder.js.map +0 -1
- package/dist-node/builders/SdCliTypescriptBuilder.js +0 -347
- package/dist-node/builders/SdCliTypescriptBuilder.js.map +0 -1
- package/dist-node/commons.js +0 -3
- package/dist-node/commons.js.map +0 -1
- package/dist-node/entry-points/SdCliLocalUpdater.js +0 -88
- package/dist-node/entry-points/SdCliLocalUpdater.js.map +0 -1
- package/dist-node/entry-points/SdCliPrepare.js +0 -56
- package/dist-node/entry-points/SdCliPrepare.js.map +0 -1
- package/dist-node/entry-points/SdCliProject.js +0 -302
- package/dist-node/entry-points/SdCliProject.js.map +0 -1
- package/dist-node/packages/SdCliClientPackage.js +0 -91
- package/dist-node/packages/SdCliClientPackage.js.map +0 -1
- package/dist-node/packages/SdCliLibraryPackage.js +0 -99
- package/dist-node/packages/SdCliLibraryPackage.js.map +0 -1
- package/dist-node/packages/SdCliPackageBase.js +0 -33
- package/dist-node/packages/SdCliPackageBase.js.map +0 -1
- package/dist-node/packages/SdCliServerPackage.js +0 -69
- package/dist-node/packages/SdCliServerPackage.js.map +0 -1
- package/dist-node/packages/SdCliUnknownPackage.js +0 -15
- package/dist-node/packages/SdCliUnknownPackage.js.map +0 -1
- package/dist-node/utils/SdCliFileCrypto.js +0 -76
- package/dist-node/utils/SdCliFileCrypto.js.map +0 -1
- package/dist-node/utils/SdProjectConfigUtil.js +0 -62
- package/dist-node/utils/SdProjectConfigUtil.js.map +0 -1
- package/dist-node/utils/SdTsDiagnosticUtil.js +0 -45
- package/dist-node/utils/SdTsDiagnosticUtil.js.map +0 -1
- package/dist-node/utils/SdWebpackUtil.js +0 -63
- package/dist-node/utils/SdWebpackUtil.js.map +0 -1
- package/dist-node/workers/client-ng-gen-worker.js +0 -57
- package/dist-node/workers/client-ng-gen-worker.js.map +0 -1
- package/dist-node/workers/lib-build-worker.js +0 -88
- package/dist-node/workers/lib-build-worker.js.map +0 -1
- package/dist-types/bin/sd-cli.d.ts +0 -3
- package/dist-types/bin/sd-cli.d.ts.map +0 -1
- package/dist-types/build-tools/SdCliCordova.d.ts +0 -15
- package/dist-types/build-tools/SdCliCordova.d.ts.map +0 -1
- package/dist-types/build-tools/SdCliIndexFileGenerator.d.ts +0 -13
- package/dist-types/build-tools/SdCliIndexFileGenerator.d.ts.map +0 -1
- package/dist-types/build-tools/SdCliNgModuleFilesGenerator.d.ts +0 -43
- package/dist-types/build-tools/SdCliNgModuleFilesGenerator.d.ts.map +0 -1
- package/dist-types/build-tools/metadata/SdAotMetadataReader.d.ts +0 -58
- package/dist-types/build-tools/metadata/SdAotMetadataReader.d.ts.map +0 -1
- package/dist-types/build-tools/metadata/SdIvyMetadataReader.d.ts +0 -43
- package/dist-types/build-tools/metadata/SdIvyMetadataReader.d.ts.map +0 -1
- package/dist-types/build-tools/metadata/SdMetadataError.d.ts +0 -7
- package/dist-types/build-tools/metadata/SdMetadataError.d.ts.map +0 -1
- package/dist-types/build-tools/metadata/SdMyMetadataReader.d.ts +0 -59
- package/dist-types/build-tools/metadata/SdMyMetadataReader.d.ts.map +0 -1
- package/dist-types/builders/SdCliJavascriptLinter.d.ts +0 -14
- package/dist-types/builders/SdCliJavascriptLinter.d.ts.map +0 -1
- package/dist-types/builders/SdCliNgClientBuilder.d.ts +0 -29
- package/dist-types/builders/SdCliNgClientBuilder.d.ts.map +0 -1
- package/dist-types/builders/SdCliNgLibraryBuilder.d.ts +0 -30
- package/dist-types/builders/SdCliNgLibraryBuilder.d.ts.map +0 -1
- package/dist-types/builders/SdCliPublisher.d.ts +0 -9
- package/dist-types/builders/SdCliPublisher.d.ts.map +0 -1
- package/dist-types/builders/SdCliServerBuilder.d.ts +0 -31
- package/dist-types/builders/SdCliServerBuilder.d.ts.map +0 -1
- package/dist-types/builders/SdCliTypescriptBuilder.d.ts +0 -56
- package/dist-types/builders/SdCliTypescriptBuilder.d.ts.map +0 -1
- package/dist-types/commons.d.ts +0 -134
- package/dist-types/commons.d.ts.map +0 -1
- package/dist-types/entry-points/SdCliLocalUpdater.d.ts +0 -12
- package/dist-types/entry-points/SdCliLocalUpdater.d.ts.map +0 -1
- package/dist-types/entry-points/SdCliPrepare.d.ts +0 -6
- package/dist-types/entry-points/SdCliPrepare.d.ts.map +0 -1
- package/dist-types/entry-points/SdCliProject.d.ts +0 -32
- package/dist-types/entry-points/SdCliProject.d.ts.map +0 -1
- package/dist-types/packages/SdCliClientPackage.d.ts +0 -17
- package/dist-types/packages/SdCliClientPackage.d.ts.map +0 -1
- package/dist-types/packages/SdCliLibraryPackage.d.ts +0 -20
- package/dist-types/packages/SdCliLibraryPackage.d.ts.map +0 -1
- package/dist-types/packages/SdCliPackageBase.d.ts +0 -11
- package/dist-types/packages/SdCliPackageBase.d.ts.map +0 -1
- package/dist-types/packages/SdCliServerPackage.d.ts +0 -16
- package/dist-types/packages/SdCliServerPackage.d.ts.map +0 -1
- package/dist-types/packages/SdCliUnknownPackage.d.ts +0 -9
- package/dist-types/packages/SdCliUnknownPackage.d.ts.map +0 -1
- package/dist-types/utils/SdCliFileCrypto.d.ts +0 -8
- package/dist-types/utils/SdCliFileCrypto.d.ts.map +0 -1
- package/dist-types/utils/SdProjectConfigUtil.d.ts +0 -7
- package/dist-types/utils/SdProjectConfigUtil.d.ts.map +0 -1
- package/dist-types/utils/SdTsDiagnosticUtil.d.ts +0 -6
- package/dist-types/utils/SdTsDiagnosticUtil.d.ts.map +0 -1
- package/dist-types/utils/SdWebpackUtil.d.ts +0 -7
- package/dist-types/utils/SdWebpackUtil.d.ts.map +0 -1
- package/dist-types/workers/client-ng-gen-worker.d.ts +0 -2
- package/dist-types/workers/client-ng-gen-worker.d.ts.map +0 -1
- package/dist-types/workers/lib-build-worker.d.ts +0 -2
- package/dist-types/workers/lib-build-worker.d.ts.map +0 -1
- package/schema/schema.json +0 -447
- package/sd-tsconfig.node.json +0 -18
- package/src/build-tools/SdCliCordova.ts +0 -240
- package/src/build-tools/SdCliIndexFileGenerator.ts +0 -61
- package/src/build-tools/SdCliNgModuleFilesGenerator.ts +0 -894
- package/src/build-tools/metadata/SdAotMetadataReader.ts +0 -374
- package/src/build-tools/metadata/SdIvyMetadataReader.ts +0 -183
- package/src/build-tools/metadata/SdMetadataError.ts +0 -7
- package/src/build-tools/metadata/SdMyMetadataReader.ts +0 -407
- package/src/builders/SdCliJavascriptLinter.ts +0 -81
- package/src/builders/SdCliNgClientBuilder.ts +0 -793
- package/src/builders/SdCliNgLibraryBuilder.ts +0 -301
- package/src/builders/SdCliPublisher.ts +0 -144
- package/src/builders/SdCliServerBuilder.ts +0 -555
- package/src/builders/SdCliTypescriptBuilder.ts +0 -552
- package/src/entry-points/SdCliLocalUpdater.ts +0 -114
- package/src/entry-points/SdCliPrepare.ts +0 -104
- package/src/entry-points/SdCliProject.ts +0 -405
- package/src/packages/SdCliClientPackage.ts +0 -111
- package/src/packages/SdCliLibraryPackage.ts +0 -118
- package/src/packages/SdCliPackageBase.ts +0 -34
- package/src/packages/SdCliServerPackage.ts +0 -85
- package/src/packages/SdCliUnknownPackage.ts +0 -14
- package/src/utils/SdCliFileCrypto.ts +0 -87
- package/src/utils/SdCliUtils.ts +0 -56
- package/src/utils/SdProjectConfigUtil.ts +0 -145
- package/src/utils/SdTsDiagnosticUtil.ts +0 -46
- package/src/utils/SdWebpackUtil.ts +0 -71
- package/src/workers/client-ng-gen-worker.ts +0 -63
- package/src/workers/lib-build-worker.ts +0 -97
|
@@ -1,793 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "events";
|
|
2
|
-
import {
|
|
3
|
-
INpmConfig,
|
|
4
|
-
ISdClientCordovaPlatformConfig,
|
|
5
|
-
ISdClientPackageConfig,
|
|
6
|
-
ISdPackageBuildResult,
|
|
7
|
-
ITsconfig,
|
|
8
|
-
TSdClientPlatformConfig
|
|
9
|
-
} from "../commons";
|
|
10
|
-
import * as webpack from "webpack";
|
|
11
|
-
import * as path from "path";
|
|
12
|
-
import * as ts from "typescript";
|
|
13
|
-
import { FsUtil, Logger, PathUtil, SdProcessWorker } from "@simplysm/sd-core-node";
|
|
14
|
-
import {
|
|
15
|
-
JavaScriptOptimizerPlugin
|
|
16
|
-
} from "@angular-devkit/build-angular/src/webpack/plugins/javascript-optimizer-plugin";
|
|
17
|
-
import * as CssMinimizerPlugin from "css-minimizer-webpack-plugin";
|
|
18
|
-
import * as esbuild from "esbuild";
|
|
19
|
-
import {
|
|
20
|
-
CommonJsUsageWarnPlugin,
|
|
21
|
-
DedupeModuleResolvePlugin,
|
|
22
|
-
SuppressExtractedTextChunksWebpackPlugin
|
|
23
|
-
} from "@angular-devkit/build-angular/src/webpack/plugins";
|
|
24
|
-
import { LicenseWebpackPlugin } from "license-webpack-plugin";
|
|
25
|
-
import { SassWorkerImplementation } from "@angular-devkit/build-angular/src/sass/sass-service";
|
|
26
|
-
import * as MiniCssExtractPlugin from "mini-css-extract-plugin";
|
|
27
|
-
import { AngularWebpackPlugin } from "@ngtools/webpack";
|
|
28
|
-
import { SdWebpackUtil } from "../utils/SdWebpackUtil";
|
|
29
|
-
import { IndexHtmlWebpackPlugin } from "@angular-devkit/build-angular/src/webpack/plugins/index-html-webpack-plugin";
|
|
30
|
-
import * as CopyWebpackPlugin from "copy-webpack-plugin";
|
|
31
|
-
import { NextHandleFunction } from "connect";
|
|
32
|
-
import { HmrLoader } from "@angular-devkit/build-angular/src/webpack/plugins/hmr/hmr-loader";
|
|
33
|
-
import * as WebpackDevMiddleware from "webpack-dev-middleware";
|
|
34
|
-
import { StringUtil, Wait } from "@simplysm/sd-core-common";
|
|
35
|
-
import { augmentAppWithServiceWorker } from "@angular-devkit/build-angular/src/utils/service-worker";
|
|
36
|
-
import * as browserslist from "browserslist";
|
|
37
|
-
import * as WebpackHotMiddleware from "webpack-hot-middleware";
|
|
38
|
-
import * as os from "os";
|
|
39
|
-
import { LintResult } from "eslint-webpack-plugin/declarations/options";
|
|
40
|
-
import { SdCliCordova } from "../build-tools/SdCliCordova";
|
|
41
|
-
import * as JSZip from "jszip";
|
|
42
|
-
import * as NodePolyfillPlugin from "node-polyfill-webpack-plugin";
|
|
43
|
-
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
45
|
-
const ESLintWebpackPlugin = require("eslint-webpack-plugin");
|
|
46
|
-
|
|
47
|
-
export class SdCliNgClientBuilder extends EventEmitter {
|
|
48
|
-
public parsedTsconfig: ts.ParsedCommandLine;
|
|
49
|
-
public readonly npmConfig: INpmConfig;
|
|
50
|
-
|
|
51
|
-
private _ngGenWorker?: SdProcessWorker;
|
|
52
|
-
|
|
53
|
-
protected readonly _logger: Logger;
|
|
54
|
-
|
|
55
|
-
private get _platformConfig(): TSdClientPlatformConfig {
|
|
56
|
-
return this.config.platforms!.single((item) => item.type === this.platformType)!;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public constructor(public rootPath: string,
|
|
60
|
-
public tsconfigFilePath: string,
|
|
61
|
-
public projectRootPath: string,
|
|
62
|
-
public config: ISdClientPackageConfig,
|
|
63
|
-
public platformType: TSdClientPlatformConfig["type"],
|
|
64
|
-
public skipProcesses: ("lint" | "genNgModule")[]) {
|
|
65
|
-
super();
|
|
66
|
-
|
|
67
|
-
const tsconfig: ITsconfig = FsUtil.readJson(this.tsconfigFilePath);
|
|
68
|
-
this.parsedTsconfig = ts.parseJsonConfigFileContent(tsconfig, ts.sys, this.rootPath, tsconfig.angularCompilerOptions);
|
|
69
|
-
|
|
70
|
-
this.npmConfig = FsUtil.readJson(path.resolve(this.rootPath, "package.json"));
|
|
71
|
-
|
|
72
|
-
this._logger = Logger.get(["simplysm", "sd-cli", this.constructor.name, this.npmConfig.name]);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
public on(event: "change", listener: () => void): this;
|
|
76
|
-
public on(event: "complete", listener: (results: ISdPackageBuildResult[]) => void): this;
|
|
77
|
-
public on(event: string | symbol, listener: (...args: any[]) => void): this {
|
|
78
|
-
return super.on(event, listener);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
public async buildAsync(): Promise<void> {
|
|
82
|
-
this.emit("change");
|
|
83
|
-
|
|
84
|
-
await FsUtil.removeAsync(this.parsedTsconfig.options.outDir!);
|
|
85
|
-
|
|
86
|
-
const buildResult: ISdPackageBuildResult[] = [];
|
|
87
|
-
|
|
88
|
-
// CORDOVA 초기화
|
|
89
|
-
const cordova = this.platformType !== "cordova" ? undefined
|
|
90
|
-
: new SdCliCordova(this.rootPath, this._platformConfig as ISdClientCordovaPlatformConfig);
|
|
91
|
-
if (cordova) {
|
|
92
|
-
await cordova.initializeAsync();
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// GENERATOR
|
|
96
|
-
if (!this.skipProcesses.includes("genNgModule")) {
|
|
97
|
-
this._logger.debug("NgGen 수행");
|
|
98
|
-
const genResult = await this._runNgGenWorkerAsync(false);
|
|
99
|
-
buildResult.push(...genResult.result);
|
|
100
|
-
this._logger.debug("NgGen 수행 결과", genResult);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// WEBPACK 빌드
|
|
104
|
-
this._logger.debug("Webpack 빌드 수행");
|
|
105
|
-
const webpackConfig = this._getWebpackConfig(false);
|
|
106
|
-
const compiler = webpack(webpackConfig);
|
|
107
|
-
const webpackBuildResults = await new Promise<ISdPackageBuildResult[]>((resolve, reject) => {
|
|
108
|
-
compiler.run(async (err, stat) => {
|
|
109
|
-
if (err != null) {
|
|
110
|
-
reject(err);
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (cordova) {
|
|
115
|
-
await cordova.buildAsync(this.parsedTsconfig.options.outDir!);
|
|
116
|
-
|
|
117
|
-
const platformConfig = this._platformConfig as ISdClientCordovaPlatformConfig;
|
|
118
|
-
|
|
119
|
-
const zip = new JSZip();
|
|
120
|
-
const resultFiles = await FsUtil.globAsync(path.resolve(this.rootPath, ".cordova", "www", "**/*"), {
|
|
121
|
-
dot: true,
|
|
122
|
-
nodir: true
|
|
123
|
-
});
|
|
124
|
-
for (const resultFile of resultFiles) {
|
|
125
|
-
const contentBuffer = await FsUtil.readFileBufferAsync(resultFile);
|
|
126
|
-
|
|
127
|
-
const relativePath = path.relative(path.resolve(this.rootPath, ".cordova", "www"), resultFile);
|
|
128
|
-
zip.file("/" + relativePath, contentBuffer);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const zipFileName = path.basename(`${platformConfig.appName}-v${this.npmConfig.version}.zip`);
|
|
132
|
-
const resultBuffer = await zip.generateAsync({ type: "nodebuffer" });
|
|
133
|
-
|
|
134
|
-
await FsUtil.writeFileAsync(path.resolve(this.parsedTsconfig.options.outDir!, "updates/", zipFileName), resultBuffer);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const results = SdWebpackUtil.getWebpackResults(stat!);
|
|
138
|
-
resolve(results);
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
this._logger.debug("Webpack 빌드 결과", webpackBuildResults);
|
|
142
|
-
buildResult.push(...webpackBuildResults);
|
|
143
|
-
|
|
144
|
-
// .config.json 파일 쓰기
|
|
145
|
-
|
|
146
|
-
const targetPath = path.resolve(this.parsedTsconfig.options.outDir!, ".config.json");
|
|
147
|
-
await FsUtil.writeFileAsync(targetPath, JSON.stringify(this.config.configs ?? {}, undefined, 2));
|
|
148
|
-
|
|
149
|
-
// service-worker 처리
|
|
150
|
-
|
|
151
|
-
if (FsUtil.exists(path.resolve(this.rootPath, "ngsw-config.json"))) {
|
|
152
|
-
const packageKey = this.npmConfig.name.split("/").last()!;
|
|
153
|
-
await augmentAppWithServiceWorker(
|
|
154
|
-
PathUtil.posix(this.projectRootPath) as any,
|
|
155
|
-
PathUtil.posix(path.relative(this.projectRootPath, this.rootPath)) as any,
|
|
156
|
-
PathUtil.posix(path.relative(this.projectRootPath, this.parsedTsconfig.options.outDir!)) as any,
|
|
157
|
-
`/${packageKey}/`,
|
|
158
|
-
PathUtil.posix(path.relative(this.projectRootPath, path.resolve(this.rootPath, "ngsw-config.json")))
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
this.emit("complete", buildResult.distinct());
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
public async watchAsync(serverPath?: string): Promise<NextHandleFunction[]> {
|
|
166
|
-
await FsUtil.removeAsync(this.parsedTsconfig.options.outDir!);
|
|
167
|
-
|
|
168
|
-
const ngGenResultsMap = new Map<string, ISdPackageBuildResult[]>();
|
|
169
|
-
const addNgGenResults = (r: ISdPackageBuildResult[]): void => {
|
|
170
|
-
for (const item of r) {
|
|
171
|
-
const arr = ngGenResultsMap.getOrCreate(item.filePath !== undefined ? PathUtil.posix(item.filePath) : "undefined", []);
|
|
172
|
-
arr.push(item);
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
const removeNgGenResults = (filePaths: string[]): void => {
|
|
176
|
-
for (const filePath of filePaths) {
|
|
177
|
-
ngGenResultsMap.delete(PathUtil.posix(filePath));
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
const getNgGenResults = (): ISdPackageBuildResult[] => {
|
|
181
|
-
return Array.from(ngGenResultsMap.values()).mapMany().distinct();
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
// CORDOVA 초기화
|
|
185
|
-
const cordova = this.platformType !== "cordova" ? undefined
|
|
186
|
-
: new SdCliCordova(this.rootPath, this._platformConfig as ISdClientCordovaPlatformConfig);
|
|
187
|
-
if (cordova) {
|
|
188
|
-
await cordova.initializeAsync();
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// WEBPACK 빌드
|
|
192
|
-
let invalidFiles = new Set<string>();
|
|
193
|
-
const webpackConfig = this._getWebpackConfig(true);
|
|
194
|
-
const compiler = webpack(webpackConfig);
|
|
195
|
-
return await new Promise<NextHandleFunction[]>((resolve, reject) => {
|
|
196
|
-
compiler.hooks.invalid.tap(this.constructor.name, (fileName) => {
|
|
197
|
-
if (fileName != null) {
|
|
198
|
-
invalidFiles.add(fileName);
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
compiler.hooks.watchRun.tapAsync(this.constructor.name, async (compiler1, callback) => {
|
|
203
|
-
this.emit("change");
|
|
204
|
-
|
|
205
|
-
// -- FIRST
|
|
206
|
-
|
|
207
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition,@typescript-eslint/strict-boolean-expressions
|
|
208
|
-
if (invalidFiles.size === 0) {
|
|
209
|
-
if (!this.skipProcesses.includes("genNgModule")) {
|
|
210
|
-
this._logger.debug("첫 NgGen 수행");
|
|
211
|
-
const genResult = await this._runNgGenWorkerAsync(true);
|
|
212
|
-
addNgGenResults(genResult.result);
|
|
213
|
-
this._logger.debug("첫 NgGen 수행 결과", genResult);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
this._logger.debug("Webpack 빌드 수행");
|
|
217
|
-
callback();
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// -- NOT FIRST
|
|
221
|
-
else {
|
|
222
|
-
// 변경파일 중, 유효한 파일 추출
|
|
223
|
-
const changedFiles = [...invalidFiles];
|
|
224
|
-
invalidFiles = new Set<string>();
|
|
225
|
-
|
|
226
|
-
const changedFilePaths = changedFiles
|
|
227
|
-
.map((item) => PathUtil.posix(item))
|
|
228
|
-
.filter((item) => path.basename(item).includes("."))
|
|
229
|
-
.distinct();
|
|
230
|
-
if (changedFilePaths.length === 0) {
|
|
231
|
-
this._logger.debug("Webpack 빌드 수행");
|
|
232
|
-
callback();
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
removeNgGenResults(["undefined"]);
|
|
236
|
-
removeNgGenResults(changedFilePaths);
|
|
237
|
-
|
|
238
|
-
if (!this.skipProcesses.includes("genNgModule")) {
|
|
239
|
-
this._logger.debug("변경파일에 대한, NgGen 수행", changedFilePaths);
|
|
240
|
-
|
|
241
|
-
const genResult = await this._runNgGenWorkerAsync(true, changedFilePaths);
|
|
242
|
-
if (genResult.dirtyFilePaths.length === 0) {
|
|
243
|
-
this._logger.debug("변경파일에 대한, NgGen 결과", genResult);
|
|
244
|
-
this._logger.debug("Webpack 빌드 수행");
|
|
245
|
-
callback();
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
removeNgGenResults(genResult.dirtyFilePaths);
|
|
249
|
-
addNgGenResults(genResult.result);
|
|
250
|
-
|
|
251
|
-
this._logger.debug("변경파일에 대한, NgGen 결과", genResult);
|
|
252
|
-
|
|
253
|
-
const modifiedFiles = [...compiler.modifiedFiles];
|
|
254
|
-
const removedFiles = [...compiler.removedFiles];
|
|
255
|
-
for (const genFilePath of genResult.dirtyFilePaths.distinct()) {
|
|
256
|
-
if (FsUtil.exists(genFilePath)) {
|
|
257
|
-
modifiedFiles.push(genFilePath);
|
|
258
|
-
}
|
|
259
|
-
else {
|
|
260
|
-
removedFiles.push(genFilePath);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
compiler.modifiedFiles = new Set(modifiedFiles.distinct());
|
|
264
|
-
compiler.removedFiles = new Set(removedFiles.distinct());
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
this._logger.debug("Webpack 빌드 수행");
|
|
268
|
-
callback();
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
// eslint-disable-next-line prefer-const
|
|
273
|
-
let devMiddleware: NextHandleFunction | undefined;
|
|
274
|
-
// eslint-disable-next-line prefer-const
|
|
275
|
-
let hotMiddleware: NextHandleFunction | undefined;
|
|
276
|
-
|
|
277
|
-
compiler.hooks.failed.tap(this.constructor.name, (err) => {
|
|
278
|
-
const results = SdWebpackUtil.getWebpackResults(err);
|
|
279
|
-
const allResults = [...getNgGenResults(), ...results].distinct();
|
|
280
|
-
this.emit("complete", allResults);
|
|
281
|
-
this._logger.debug("Webpack 빌드 수행 결과", allResults);
|
|
282
|
-
reject(err);
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
compiler.hooks.done.tap("SdCliClientCompiler", async (stats) => {
|
|
286
|
-
const results = SdWebpackUtil.getWebpackResults(stats);
|
|
287
|
-
|
|
288
|
-
// .config.json 파일 쓰기
|
|
289
|
-
const packageKey = this.npmConfig.name.split("/").last()!;
|
|
290
|
-
const configDistPath = !StringUtil.isNullOrEmpty(serverPath)
|
|
291
|
-
? path.resolve(serverPath, "dist/www", packageKey, ".config.json")
|
|
292
|
-
: path.resolve(this.parsedTsconfig.options.outDir!, ".config.json");
|
|
293
|
-
await FsUtil.writeFileAsync(configDistPath, JSON.stringify(this.config.configs ?? {}, undefined, 2));
|
|
294
|
-
|
|
295
|
-
/*if (cordova) {
|
|
296
|
-
const platformConfig = this._platformConfig as ISdClientCordovaPlatformConfig;
|
|
297
|
-
|
|
298
|
-
const zip = new JSZip();
|
|
299
|
-
const resultFiles = await FsUtil.globAsync(path.resolve(this.rootPath, ".cordova", "www", "**!/!*"), {
|
|
300
|
-
dot: true,
|
|
301
|
-
nodir: true
|
|
302
|
-
});
|
|
303
|
-
for (const resultFile of resultFiles) {
|
|
304
|
-
const contentBuffer = await FsUtil.readFileBufferAsync(resultFile);
|
|
305
|
-
|
|
306
|
-
const relativePath = path.relative(path.resolve(this.rootPath, ".cordova", "www"), resultFile);
|
|
307
|
-
zip.file("/" + relativePath, contentBuffer);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
const zipFileName = path.basename(`${platformConfig.appName}-v${this.npmConfig.version}.zip`);
|
|
311
|
-
const resultBuffer = await zip.generateAsync({ type: "nodebuffer" });
|
|
312
|
-
|
|
313
|
-
await FsUtil.writeFileAsync(path.resolve(this.parsedTsconfig.options.outDir!, "updates/", zipFileName), resultBuffer);
|
|
314
|
-
}*/
|
|
315
|
-
|
|
316
|
-
await Wait.true(() => devMiddleware !== undefined && hotMiddleware !== undefined);
|
|
317
|
-
const allResults = [...getNgGenResults(), ...results].distinct();
|
|
318
|
-
this.emit("complete", allResults);
|
|
319
|
-
this._logger.debug("Webpack 빌드 수행 결과", allResults);
|
|
320
|
-
resolve([devMiddleware!, hotMiddleware!]);
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
devMiddleware = WebpackDevMiddleware(compiler, {
|
|
324
|
-
publicPath: webpackConfig.output!.publicPath as string,
|
|
325
|
-
index: "index.html",
|
|
326
|
-
headers: { "Access-Control-Allow-Origin": "*" },
|
|
327
|
-
stats: false
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
hotMiddleware = WebpackHotMiddleware(compiler, {
|
|
331
|
-
path: `${webpackConfig.output!.publicPath as string}__webpack_hmr`,
|
|
332
|
-
log: false
|
|
333
|
-
});
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
private _getWebpackConfig(watch: boolean): webpack.Configuration {
|
|
338
|
-
const nodeSass = new SassWorkerImplementation();
|
|
339
|
-
|
|
340
|
-
const packageKey = this.npmConfig.name.split("/").last()!;
|
|
341
|
-
|
|
342
|
-
const distPath = (this.platformType === "cordova" && !watch) ? path.resolve(this.rootPath, ".cordova", "www")
|
|
343
|
-
: this.parsedTsconfig.options.outDir;
|
|
344
|
-
|
|
345
|
-
const publicPath = (this.platformType === "cordova" && !watch) ? ""
|
|
346
|
-
: (this.platformType !== "browser" ? `/__${this.platformType}` : "") + `/${packageKey}/`;
|
|
347
|
-
|
|
348
|
-
return {
|
|
349
|
-
mode: watch ? "development" : "production",
|
|
350
|
-
devtool: false,
|
|
351
|
-
target: ["web", "es2015"],
|
|
352
|
-
profile: false,
|
|
353
|
-
resolve: {
|
|
354
|
-
roots: [this.rootPath],
|
|
355
|
-
extensions: [".ts", ".js"],
|
|
356
|
-
symlinks: true,
|
|
357
|
-
// modules: allNodeModulePaths,
|
|
358
|
-
mainFields: ["es2015", "browser", "module", "main"],
|
|
359
|
-
fallback: this.config.resolveFallback
|
|
360
|
-
},
|
|
361
|
-
/*resolveLoader: {
|
|
362
|
-
symlinks: true,
|
|
363
|
-
modules: allNodeModulePaths
|
|
364
|
-
},*/
|
|
365
|
-
context: this.projectRootPath,
|
|
366
|
-
entry: {
|
|
367
|
-
main: [
|
|
368
|
-
...watch ? [
|
|
369
|
-
`webpack-hot-middleware/client?path=${publicPath}__webpack_hmr&timeout=20000&reload=true&overlay=true`
|
|
370
|
-
] : [],
|
|
371
|
-
path.resolve(this.rootPath, "src/main.ts")
|
|
372
|
-
],
|
|
373
|
-
polyfills: [
|
|
374
|
-
path.resolve(this.rootPath, "src/polyfills.ts")
|
|
375
|
-
],
|
|
376
|
-
styles: [
|
|
377
|
-
path.resolve(this.rootPath, "src/styles.scss")
|
|
378
|
-
]
|
|
379
|
-
},
|
|
380
|
-
output: {
|
|
381
|
-
clean: true,
|
|
382
|
-
path: distPath,
|
|
383
|
-
publicPath,
|
|
384
|
-
// filename: watch ? "[name].js" : `[name].[chunkhash:20].js`,
|
|
385
|
-
// chunkFilename: watch ? "[name].js" : "[name].[chunkhash:20].js",
|
|
386
|
-
filename: "[name].js",
|
|
387
|
-
chunkFilename: "[name].js",
|
|
388
|
-
assetModuleFilename: "resources/[name][ext][query]",
|
|
389
|
-
crossOriginLoading: false,
|
|
390
|
-
trustedTypes: "angular#bundler"
|
|
391
|
-
},
|
|
392
|
-
...watch ? {
|
|
393
|
-
watchOptions: { poll: undefined, ignored: "**/$_lazy_route_resources" }
|
|
394
|
-
} : {
|
|
395
|
-
watch: false
|
|
396
|
-
},
|
|
397
|
-
performance: { hints: false },
|
|
398
|
-
ignoreWarnings: [
|
|
399
|
-
/System.import\(\) is deprecated and will be removed soon/i,
|
|
400
|
-
/Failed to parse source map from/,
|
|
401
|
-
/Add postcss as project dependency/
|
|
402
|
-
],
|
|
403
|
-
module: {
|
|
404
|
-
strictExportPresence: true,
|
|
405
|
-
rules: [
|
|
406
|
-
...watch ? [
|
|
407
|
-
{
|
|
408
|
-
loader: HmrLoader,
|
|
409
|
-
include: [path.resolve(this.rootPath, "src/main.ts")]
|
|
410
|
-
}
|
|
411
|
-
] : [],
|
|
412
|
-
{
|
|
413
|
-
test: /[/\\]@angular[/\\]core[/\\].+\.js$/,
|
|
414
|
-
parser: { system: true }
|
|
415
|
-
},
|
|
416
|
-
{
|
|
417
|
-
test: /[/\\]rxjs[/\\]add[/\\].+\.js$/,
|
|
418
|
-
sideEffects: true
|
|
419
|
-
},
|
|
420
|
-
...watch ? [
|
|
421
|
-
{
|
|
422
|
-
test: /\.m?js$/,
|
|
423
|
-
enforce: "pre",
|
|
424
|
-
loader: require.resolve("source-map-loader"),
|
|
425
|
-
options: {
|
|
426
|
-
filterSourceMappingUrl: (mapUri: string, resourcePath: string) => {
|
|
427
|
-
return !resourcePath.includes("node_modules") || (/@simplysm[\\/]sd/).test(resourcePath);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
] as any : [],
|
|
432
|
-
/*
|
|
433
|
-
{
|
|
434
|
-
test: /\.m?js/,
|
|
435
|
-
resolve: {
|
|
436
|
-
fullySpecified: false
|
|
437
|
-
}
|
|
438
|
-
},*/
|
|
439
|
-
{
|
|
440
|
-
test: /\.scss$/i,
|
|
441
|
-
rules: [
|
|
442
|
-
{
|
|
443
|
-
oneOf: [
|
|
444
|
-
{
|
|
445
|
-
include: path.resolve(this.rootPath, "src/styles.scss"),
|
|
446
|
-
use: [
|
|
447
|
-
{
|
|
448
|
-
loader: MiniCssExtractPlugin.loader
|
|
449
|
-
},
|
|
450
|
-
{
|
|
451
|
-
loader: "css-loader",
|
|
452
|
-
options: {
|
|
453
|
-
url: false,
|
|
454
|
-
sourceMap: watch
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
]
|
|
458
|
-
},
|
|
459
|
-
{
|
|
460
|
-
exclude: path.resolve(this.rootPath, "src/styles.scss"),
|
|
461
|
-
type: "asset/source"
|
|
462
|
-
}
|
|
463
|
-
]
|
|
464
|
-
},
|
|
465
|
-
{
|
|
466
|
-
use: [
|
|
467
|
-
{
|
|
468
|
-
loader: "resolve-url-loader",
|
|
469
|
-
options: {
|
|
470
|
-
sourceMap: watch
|
|
471
|
-
}
|
|
472
|
-
},
|
|
473
|
-
{
|
|
474
|
-
loader: "sass-loader",
|
|
475
|
-
options: {
|
|
476
|
-
implementation: nodeSass,
|
|
477
|
-
sourceMap: true,
|
|
478
|
-
sassOptions: {
|
|
479
|
-
fiber: false,
|
|
480
|
-
precision: 8,
|
|
481
|
-
includePaths: [],
|
|
482
|
-
outputStyle: "expanded",
|
|
483
|
-
quietDeps: true,
|
|
484
|
-
verbose: false
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
]
|
|
489
|
-
}
|
|
490
|
-
]
|
|
491
|
-
},
|
|
492
|
-
{
|
|
493
|
-
test: /\.[jt]sx?$/,
|
|
494
|
-
loader: "@ngtools/webpack"
|
|
495
|
-
},
|
|
496
|
-
{
|
|
497
|
-
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico|otf|xlsx?|pptx?|docx?|zip|pfx|pkl)$/,
|
|
498
|
-
type: "asset/resource"
|
|
499
|
-
}
|
|
500
|
-
]
|
|
501
|
-
},
|
|
502
|
-
experiments: { syncWebAssembly: true, asyncWebAssembly: true },
|
|
503
|
-
...watch ? {
|
|
504
|
-
cache: { type: "memory", maxGenerations: 1 },
|
|
505
|
-
snapshot: {
|
|
506
|
-
immutablePaths: this._findAllInternalModuleCachePaths(),
|
|
507
|
-
managedPaths: this._findAllInternalModuleCachePaths()
|
|
508
|
-
}
|
|
509
|
-
} : {
|
|
510
|
-
cache: false
|
|
511
|
-
},
|
|
512
|
-
optimization: {
|
|
513
|
-
minimizer: watch ? [] : [
|
|
514
|
-
new JavaScriptOptimizerPlugin({
|
|
515
|
-
define: { ngDevMode: false, ngI18nClosureMode: false, ngJitMode: false },
|
|
516
|
-
sourcemap: false,
|
|
517
|
-
target: this.parsedTsconfig.options.target,
|
|
518
|
-
keepNames: true,
|
|
519
|
-
removeLicenses: true,
|
|
520
|
-
advanced: true
|
|
521
|
-
}) as any,
|
|
522
|
-
new CssMinimizerPlugin({
|
|
523
|
-
test: /\.(css|scss)$/,
|
|
524
|
-
exclude: "styles.css",
|
|
525
|
-
parallel: false,
|
|
526
|
-
minify: async (data: string) => {
|
|
527
|
-
const [[sourcefile, input]] = Object.entries(data);
|
|
528
|
-
const { code, warnings } = await esbuild.transform(input, {
|
|
529
|
-
loader: "css",
|
|
530
|
-
minify: true,
|
|
531
|
-
sourcefile,
|
|
532
|
-
target: browserslist([
|
|
533
|
-
"last 2 Chrome versions",
|
|
534
|
-
"last 2 Edge major versions"
|
|
535
|
-
]).map((item) => item.replace(/ /g, ""))
|
|
536
|
-
});
|
|
537
|
-
|
|
538
|
-
return {
|
|
539
|
-
code,
|
|
540
|
-
warnings:
|
|
541
|
-
warnings.length > 0
|
|
542
|
-
? await esbuild.formatMessages(warnings, { kind: "warning" })
|
|
543
|
-
: []
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
}),
|
|
547
|
-
new CssMinimizerPlugin({
|
|
548
|
-
test: /\.css$/,
|
|
549
|
-
include: "styles.css",
|
|
550
|
-
parallel: 4,
|
|
551
|
-
minify: [CssMinimizerPlugin.cssnanoMinify],
|
|
552
|
-
minimizerOptions: {
|
|
553
|
-
preset: [
|
|
554
|
-
"default",
|
|
555
|
-
{
|
|
556
|
-
svgo: false,
|
|
557
|
-
calc: false,
|
|
558
|
-
cssDeclarationSorter: false,
|
|
559
|
-
minifyParams: false
|
|
560
|
-
}
|
|
561
|
-
]
|
|
562
|
-
}
|
|
563
|
-
})
|
|
564
|
-
],
|
|
565
|
-
moduleIds: "deterministic",
|
|
566
|
-
chunkIds: watch ? "named" : "deterministic",
|
|
567
|
-
emitOnErrors: watch,
|
|
568
|
-
runtimeChunk: "single",
|
|
569
|
-
splitChunks: {
|
|
570
|
-
maxAsyncRequests: Infinity,
|
|
571
|
-
cacheGroups: {
|
|
572
|
-
default: { chunks: "async", minChunks: 2, priority: 10 },
|
|
573
|
-
common: {
|
|
574
|
-
name: "common",
|
|
575
|
-
chunks: "async",
|
|
576
|
-
minChunks: 2,
|
|
577
|
-
enforce: true,
|
|
578
|
-
priority: 5
|
|
579
|
-
},
|
|
580
|
-
vendors: false,
|
|
581
|
-
defaultVendors: watch ? {
|
|
582
|
-
name: "vendor",
|
|
583
|
-
chunks: (chunk) => chunk.name === "main",
|
|
584
|
-
enforce: true,
|
|
585
|
-
test: /[\\/]node_modules[\\/]/
|
|
586
|
-
} : false
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
},
|
|
590
|
-
plugins: [
|
|
591
|
-
new NodePolyfillPlugin(),
|
|
592
|
-
new webpack.ContextReplacementPlugin(
|
|
593
|
-
/@angular[\\/]core[\\/]/,
|
|
594
|
-
path.join(this.rootPath, "$_lazy_route_resources"),
|
|
595
|
-
{}
|
|
596
|
-
),
|
|
597
|
-
new DedupeModuleResolvePlugin({ verbose: false }) as any,
|
|
598
|
-
new CopyWebpackPlugin({
|
|
599
|
-
patterns: [
|
|
600
|
-
...["favicon.ico", "assets/", "manifest.webmanifest"].map((item) => ({
|
|
601
|
-
context: this.rootPath,
|
|
602
|
-
to: item,
|
|
603
|
-
from: `src/${item}`,
|
|
604
|
-
noErrorOnMissing: true,
|
|
605
|
-
force: true,
|
|
606
|
-
globOptions: {
|
|
607
|
-
dot: true,
|
|
608
|
-
followSymbolicLinks: false,
|
|
609
|
-
ignore: [
|
|
610
|
-
".gitkeep",
|
|
611
|
-
"**/.DS_Store",
|
|
612
|
-
"**/Thumbs.db"
|
|
613
|
-
].map((i) => PathUtil.posix(this.rootPath, i))
|
|
614
|
-
},
|
|
615
|
-
priority: 0
|
|
616
|
-
})),
|
|
617
|
-
...this.platformType === "cordova" ? [
|
|
618
|
-
...(this._platformConfig as ISdClientCordovaPlatformConfig).targets.map((target) => ({
|
|
619
|
-
context: this.rootPath,
|
|
620
|
-
to: `cordova-${target}`,
|
|
621
|
-
from: `.cordova/platforms/${target}/platform_www`
|
|
622
|
-
})),
|
|
623
|
-
...watch ? [{
|
|
624
|
-
context: this.rootPath,
|
|
625
|
-
to: `cordova-browser`,
|
|
626
|
-
from: `.cordova/platforms/browser/platform_www`
|
|
627
|
-
}] : []
|
|
628
|
-
] : []
|
|
629
|
-
]
|
|
630
|
-
}),
|
|
631
|
-
...watch ? [] : [
|
|
632
|
-
new LicenseWebpackPlugin({
|
|
633
|
-
stats: { warnings: false, errors: false },
|
|
634
|
-
perChunkOutput: false,
|
|
635
|
-
outputFilename: "3rdpartylicenses.txt",
|
|
636
|
-
skipChildCompilers: true
|
|
637
|
-
})
|
|
638
|
-
],
|
|
639
|
-
new CommonJsUsageWarnPlugin(),
|
|
640
|
-
...watch ? [
|
|
641
|
-
new webpack.SourceMapDevToolPlugin({
|
|
642
|
-
filename: "[file].map",
|
|
643
|
-
include: [/js$/, /css$/],
|
|
644
|
-
sourceRoot: "webpack:///",
|
|
645
|
-
moduleFilenameTemplate: "[resource-path]",
|
|
646
|
-
append: undefined
|
|
647
|
-
})
|
|
648
|
-
] : [],
|
|
649
|
-
/*new AnyComponentStyleBudgetChecker(watch ? [] : [
|
|
650
|
-
{
|
|
651
|
-
type: Type.Any,
|
|
652
|
-
maximumWarning: "2kb",
|
|
653
|
-
maximumError: "4kb"
|
|
654
|
-
}
|
|
655
|
-
]),*/
|
|
656
|
-
{
|
|
657
|
-
apply(compiler) {
|
|
658
|
-
compiler.hooks.shutdown.tap("sass-worker", () => {
|
|
659
|
-
nodeSass.close();
|
|
660
|
-
});
|
|
661
|
-
}
|
|
662
|
-
},
|
|
663
|
-
new MiniCssExtractPlugin({
|
|
664
|
-
// filename: watch ? "[name].css" : `[name].[contenthash:20].css`
|
|
665
|
-
filename: "[name].css"
|
|
666
|
-
}),
|
|
667
|
-
...watch ? [] : [
|
|
668
|
-
new SuppressExtractedTextChunksWebpackPlugin()
|
|
669
|
-
],
|
|
670
|
-
new AngularWebpackPlugin({
|
|
671
|
-
tsconfig: this.tsconfigFilePath,
|
|
672
|
-
compilerOptions: this.parsedTsconfig.options,
|
|
673
|
-
jitMode: false,
|
|
674
|
-
emitNgModuleScope: watch,
|
|
675
|
-
inlineStyleFileExtension: "scss"
|
|
676
|
-
}),
|
|
677
|
-
new IndexHtmlWebpackPlugin({
|
|
678
|
-
indexPath: path.resolve(this.rootPath, "src/index.html"),
|
|
679
|
-
outputPath: "index.html",
|
|
680
|
-
baseHref: publicPath,
|
|
681
|
-
entrypoints: [
|
|
682
|
-
"runtime",
|
|
683
|
-
"polyfills",
|
|
684
|
-
"sw-register",
|
|
685
|
-
"styles",
|
|
686
|
-
"vendor",
|
|
687
|
-
"main"
|
|
688
|
-
],
|
|
689
|
-
moduleEntrypoints: [],
|
|
690
|
-
noModuleEntrypoints: [],
|
|
691
|
-
deployUrl: undefined,
|
|
692
|
-
sri: false,
|
|
693
|
-
postTransform: undefined,
|
|
694
|
-
optimization: {
|
|
695
|
-
scripts: !watch,
|
|
696
|
-
styles: { minify: !watch, inlineCritical: !watch },
|
|
697
|
-
fonts: { inline: !watch }
|
|
698
|
-
},
|
|
699
|
-
WOFFSupportNeeded: false,
|
|
700
|
-
crossOrigin: "none",
|
|
701
|
-
lang: undefined
|
|
702
|
-
}),
|
|
703
|
-
new webpack.EnvironmentPlugin({
|
|
704
|
-
SD_VERSION: this.npmConfig.version,
|
|
705
|
-
...this.config.env
|
|
706
|
-
}),
|
|
707
|
-
...!this.skipProcesses.includes("lint") ? [
|
|
708
|
-
new ESLintWebpackPlugin({
|
|
709
|
-
context: this.rootPath,
|
|
710
|
-
eslintPath: path.resolve(this.projectRootPath, "node_modules", "eslint"),
|
|
711
|
-
extensions: ["js", "ts"],
|
|
712
|
-
exclude: ["node_modules"],
|
|
713
|
-
fix: false,
|
|
714
|
-
threads: false,
|
|
715
|
-
formatter: (results: LintResult[]) => {
|
|
716
|
-
const resultMessages: string[] = [];
|
|
717
|
-
for (const result of results) {
|
|
718
|
-
for (const msg of result.messages) {
|
|
719
|
-
resultMessages.push(`${result.filePath}(${msg.line}, ${msg.column}): ${msg.ruleId ?? ""}: ${msg.severity === 1 ? "warning" : msg.severity === 2 ? "error" : ""} ${msg.message}`);
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
return resultMessages.join(os.EOL);
|
|
723
|
-
}
|
|
724
|
-
})
|
|
725
|
-
] : [],
|
|
726
|
-
...watch ? [
|
|
727
|
-
new webpack.HotModuleReplacementPlugin()
|
|
728
|
-
] : [],
|
|
729
|
-
/*...watch ? [
|
|
730
|
-
new webpack.WatchIgnorePlugin({
|
|
731
|
-
paths: [
|
|
732
|
-
path.resolve(this.rootPath, "src/_modules/"),
|
|
733
|
-
path.resolve(this.rootPath, "src/_routes.ts")
|
|
734
|
-
]
|
|
735
|
-
})
|
|
736
|
-
] : [],*/
|
|
737
|
-
new webpack.ProgressPlugin({
|
|
738
|
-
handler: (per: number, msg: string, ...args: string[]) => {
|
|
739
|
-
const phaseText = msg ? ` - phase: ${msg}` : "";
|
|
740
|
-
const argsText = args.length > 0 ? ` - args: [${args.join(", ")}]` : "";
|
|
741
|
-
this._logger.debug(`Webpack 빌드 수행중...(${Math.round(per * 100)}%)${phaseText}${argsText}`);
|
|
742
|
-
}
|
|
743
|
-
})
|
|
744
|
-
],
|
|
745
|
-
node: false,
|
|
746
|
-
stats: "errors-warnings"
|
|
747
|
-
};
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
private _findAllInternalModuleCachePaths(): string[] {
|
|
751
|
-
return this._findAllNodeModules(this.rootPath, this.projectRootPath)
|
|
752
|
-
.mapMany((item) => (
|
|
753
|
-
FsUtil.readdir(item)
|
|
754
|
-
.filter((item1) => item1 !== "@simplysm")
|
|
755
|
-
.map((item1) => path.resolve(item, item1))
|
|
756
|
-
));
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
private _findAllNodeModules(from: string, root: string): string[] {
|
|
760
|
-
const nodeModules: string[] = [];
|
|
761
|
-
|
|
762
|
-
let current = from;
|
|
763
|
-
while (current) {
|
|
764
|
-
const potential = path.join(current, "node_modules");
|
|
765
|
-
if (FsUtil.exists(potential) && FsUtil.isDirectory(potential)) {
|
|
766
|
-
nodeModules.push(potential);
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
if (current === root) break;
|
|
770
|
-
|
|
771
|
-
const next = path.dirname(current);
|
|
772
|
-
if (next === current) break;
|
|
773
|
-
current = next;
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
return nodeModules;
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
private async _runNgGenWorkerAsync(watch: boolean, changedFilePaths?: string[]): Promise<{ dirtyFilePaths: string[]; result: ISdPackageBuildResult[] }> {
|
|
780
|
-
if (!this._ngGenWorker) {
|
|
781
|
-
this._ngGenWorker = await SdProcessWorker.createAsync(path.resolve(__dirname, `../workers/client-ng-gen-worker`), []);
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
const sender = this._ngGenWorker.createWorkSender();
|
|
785
|
-
return await new Promise<{ dirtyFilePaths: string[]; result: ISdPackageBuildResult[] }>(async (resolve) => {
|
|
786
|
-
await sender
|
|
787
|
-
.on("complete", (result) => {
|
|
788
|
-
resolve(result);
|
|
789
|
-
})
|
|
790
|
-
.sendAsync(this.rootPath, watch, changedFilePaths);
|
|
791
|
-
});
|
|
792
|
-
}
|
|
793
|
-
}
|