@boxfoxs/scraping-bundler 0.0.9 → 1.1.0
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/dist/index.d.ts +1 -0
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -0
- package/dist/util/readJsonFile.d.ts +1 -0
- package/dist/util/readJsonFile.js +13 -0
- package/dist/util/readJsonFile.js.map +1 -0
- package/dist/util/shell.d.ts +1 -0
- package/dist/util/shell.js +36 -0
- package/dist/util/shell.js.map +1 -0
- package/dist/webpack/options/devServer.d.ts +2 -0
- package/dist/webpack/options/devServer.js +35 -0
- package/dist/webpack/options/devServer.js.map +1 -0
- package/dist/webpack/options/environments.d.ts +1 -0
- package/dist/webpack/options/environments.js +5 -0
- package/dist/webpack/options/environments.js.map +1 -0
- package/dist/webpack/options/optimization.d.ts +2 -0
- package/dist/webpack/options/optimization.js +26 -0
- package/dist/webpack/options/optimization.js.map +1 -0
- package/dist/webpack/options/rules.d.ts +2 -0
- package/dist/webpack/options/rules.js +40 -0
- package/dist/webpack/options/rules.js.map +1 -0
- package/dist/webpack/utils/getLocalhostAddresses.d.ts +1 -0
- package/dist/webpack/utils/getLocalhostAddresses.js +16 -0
- package/dist/webpack/utils/getLocalhostAddresses.js.map +1 -0
- package/dist/webpack/utils/parseAlias.d.ts +1 -0
- package/dist/webpack/utils/parseAlias.js +18 -0
- package/dist/webpack/utils/parseAlias.js.map +1 -0
- package/dist/webpack/webpack.base.config.d.ts +8 -0
- package/dist/webpack/webpack.base.config.js +88 -0
- package/dist/webpack/webpack.base.config.js.map +1 -0
- package/package.json +5 -6
- package/src/webpack/options/devServer.ts +5 -2
- package/src/webpack/options/optimization.ts +3 -2
- package/tsconfig.json +5 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './webpack/webpack.base.config';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA8C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function readJsonFile<T = any>(filePath: string): T;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.readJsonFile = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
function readJsonFile(filePath) {
|
|
9
|
+
const result = fs_1.default.readFileSync(filePath).toString();
|
|
10
|
+
return JSON.parse(result);
|
|
11
|
+
}
|
|
12
|
+
exports.readJsonFile = readJsonFile;
|
|
13
|
+
//# sourceMappingURL=readJsonFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readJsonFile.js","sourceRoot":"","sources":["../../src/util/readJsonFile.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AAEpB,SAAgB,YAAY,CAAU,QAAgB;IACpD,MAAM,MAAM,GAAG,YAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;IACpD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC;AAHD,oCAGC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function run(command: string): string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.run = void 0;
|
|
27
|
+
const shell = __importStar(require("shelljs"));
|
|
28
|
+
function run(command) {
|
|
29
|
+
const result = shell.exec(command);
|
|
30
|
+
if (result.code !== 0) {
|
|
31
|
+
throw new Error(result.stderr);
|
|
32
|
+
}
|
|
33
|
+
return result.stdout;
|
|
34
|
+
}
|
|
35
|
+
exports.run = run;
|
|
36
|
+
//# sourceMappingURL=shell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/util/shell.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;AAEjC,SAAgB,GAAG,CAAC,OAAe;IACjC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnC,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;KAChC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC;AAND,kBAMC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createDevServerOption = void 0;
|
|
7
|
+
const helmet_1 = __importDefault(require("helmet"));
|
|
8
|
+
const morgan_1 = __importDefault(require("morgan"));
|
|
9
|
+
const getLocalhostAddresses_1 = require("../utils/getLocalhostAddresses");
|
|
10
|
+
const localhostNames = (0, getLocalhostAddresses_1.getLocalhostAddresses)();
|
|
11
|
+
function createDevServerOption(staticPath) {
|
|
12
|
+
return {
|
|
13
|
+
allowedHosts: localhostNames,
|
|
14
|
+
// @ts-ignore - webpack-dev-server 4.x supports 'before' but types may not match
|
|
15
|
+
before: (app) => {
|
|
16
|
+
app.use((0, helmet_1.default)({ hsts: false }));
|
|
17
|
+
app.use((0, morgan_1.default)('dev'));
|
|
18
|
+
},
|
|
19
|
+
// @ts-ignore - webpack-dev-server 4.x supports 'after' but types may not match
|
|
20
|
+
after: () => {
|
|
21
|
+
console.log('\n\nAvailable on:');
|
|
22
|
+
console.log(`${localhostNames.map(hostname => ` http://${hostname}:10808`).join('\n')}\n`);
|
|
23
|
+
},
|
|
24
|
+
hot: false,
|
|
25
|
+
inline: false,
|
|
26
|
+
contentBase: staticPath,
|
|
27
|
+
disableHostCheck: true,
|
|
28
|
+
host: '0.0.0.0',
|
|
29
|
+
port: 10808,
|
|
30
|
+
writeToDisk: true,
|
|
31
|
+
quiet: true,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
exports.createDevServerOption = createDevServerOption;
|
|
35
|
+
//# sourceMappingURL=devServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devServer.js","sourceRoot":"","sources":["../../../src/webpack/options/devServer.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,oDAA4B;AAG5B,0EAAuE;AAEvE,MAAM,cAAc,GAAG,IAAA,6CAAqB,GAAE,CAAC;AAE/C,SAAgB,qBAAqB,CAAC,UAAkB;IACtD,OAAO;QACL,YAAY,EAAE,cAAc;QAE5B,gFAAgF;QAChF,MAAM,EAAE,CAAC,GAAgB,EAAE,EAAE;YAC3B,GAAG,CAAC,GAAG,CAAC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;YACjC,GAAG,CAAC,GAAG,CAAC,IAAA,gBAAM,EAAC,KAAK,CAAC,CAAC,CAAC;QACzB,CAAC;QAED,+EAA+E;QAC/E,KAAK,EAAE,GAAG,EAAE;YACV,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;YACjC,OAAO,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,YAAY,QAAQ,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9F,CAAC;QAED,GAAG,EAAE,KAAK;QACV,MAAM,EAAE,KAAK;QACb,WAAW,EAAE,UAAU;QACvB,gBAAgB,EAAE,IAAI;QACtB,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,IAAI;QACjB,KAAK,EAAE,IAAI;KACK,CAAC;AACrB,CAAC;AAzBD,sDAyBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BUILD_MODE: string | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environments.js","sourceRoot":"","sources":["../../../src/webpack/options/environments.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.optimizationOption = void 0;
|
|
7
|
+
const terser_webpack_plugin_1 = __importDefault(require("terser-webpack-plugin"));
|
|
8
|
+
exports.optimizationOption = {
|
|
9
|
+
usedExports: true,
|
|
10
|
+
minimizer: [
|
|
11
|
+
new terser_webpack_plugin_1.default({
|
|
12
|
+
cache: true,
|
|
13
|
+
parallel: true,
|
|
14
|
+
sourceMap: true,
|
|
15
|
+
terserOptions: {
|
|
16
|
+
warnings: false,
|
|
17
|
+
compress: { ecma: 6, dead_code: false, passes: 3 },
|
|
18
|
+
mangle: { safari10: true },
|
|
19
|
+
keep_classnames: true,
|
|
20
|
+
output: { ecma: 6, beautify: false, safari10: true, comments: false },
|
|
21
|
+
},
|
|
22
|
+
extractComments: false,
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=optimization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optimization.js","sourceRoot":"","sources":["../../../src/webpack/options/optimization.ts"],"names":[],"mappings":";;;;;;AAAA,kFAAiD;AAGpC,QAAA,kBAAkB,GAAkC;IAC/D,WAAW,EAAE,IAAI;IACjB,SAAS,EAAE;QACT,IAAI,+BAAY,CAAC;YACf,KAAK,EAAE,IAAI;YACX,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,IAAI;YACf,aAAa,EAAE;gBACb,QAAQ,EAAE,KAAK;gBACf,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE;gBAClD,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC1B,eAAe,EAAE,IAAI;gBACrB,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE;aACtE;YACD,eAAe,EAAE,KAAK;SACvB,CAAQ;KACV;CACF,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDefaultRules = void 0;
|
|
4
|
+
function createDefaultRules(sourcePath) {
|
|
5
|
+
const transpileRule = {
|
|
6
|
+
test: /\.(js|ts|jsx|tsx)$/,
|
|
7
|
+
include: sourcePath,
|
|
8
|
+
exclude: [/node_modules/, /.*preload\.js/],
|
|
9
|
+
use: {
|
|
10
|
+
loader: 'babel-loader',
|
|
11
|
+
options: {
|
|
12
|
+
presets: [
|
|
13
|
+
['@babel/preset-env', { exclude: ['@babel/plugin-transform-async-to-generator'] }],
|
|
14
|
+
],
|
|
15
|
+
plugins: [
|
|
16
|
+
['@babel/plugin-transform-typescript', { allowNamespaces: true, isTSX: true }],
|
|
17
|
+
['@babel/plugin-transform-regenerator', {}],
|
|
18
|
+
['@babel/plugin-proposal-decorators', { legacy: true }],
|
|
19
|
+
['@babel/plugin-proposal-class-properties', {}],
|
|
20
|
+
['@babel/plugin-proposal-optional-catch-binding', {}],
|
|
21
|
+
['@babel/plugin-transform-runtime', { corejs: { version: 3, proposals: true } }],
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
const preloadRule = {
|
|
27
|
+
test: /\.preload\.js$/,
|
|
28
|
+
use: [
|
|
29
|
+
{
|
|
30
|
+
loader: 'script-loader',
|
|
31
|
+
options: {
|
|
32
|
+
sourceMap: false,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
return [transpileRule, preloadRule];
|
|
38
|
+
}
|
|
39
|
+
exports.createDefaultRules = createDefaultRules;
|
|
40
|
+
//# sourceMappingURL=rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../../src/webpack/options/rules.ts"],"names":[],"mappings":";;;AAEA,SAAgB,kBAAkB,CAAC,UAAkB;IACnD,MAAM,aAAa,GAAG;QACpB,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,UAAU;QACnB,OAAO,EAAE,CAAC,cAAc,EAAE,eAAe,CAAC;QAC1C,GAAG,EAAE;YACH,MAAM,EAAE,cAAc;YACtB,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,CAAC,mBAAmB,EAAE,EAAE,OAAO,EAAE,CAAC,4CAA4C,CAAC,EAAE,CAAC;iBACnF;gBACD,OAAO,EAAE;oBACP,CAAC,oCAAoC,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;oBAC9E,CAAC,qCAAqC,EAAE,EAAE,CAAC;oBAC3C,CAAC,mCAAmC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;oBACvD,CAAC,yCAAyC,EAAE,EAAE,CAAC;oBAC/C,CAAC,+CAA+C,EAAE,EAAE,CAAC;oBACrD,CAAC,iCAAiC,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;iBACjF;aACF;SACF;KACF,CAAC;IAEF,MAAM,WAAW,GAAG;QAClB,IAAI,EAAE,gBAAgB;QACtB,GAAG,EAAE;YACH;gBACE,MAAM,EAAE,eAAe;gBACvB,OAAO,EAAE;oBACP,SAAS,EAAE,KAAK;iBACjB;aACF;SACF;KACF,CAAC;IACF,OAAO,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;AACtC,CAAC;AAnCD,gDAmCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getLocalhostAddresses(): string[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getLocalhostAddresses = void 0;
|
|
7
|
+
const lodash_1 = require("lodash");
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
9
|
+
function getLocalhostAddresses() {
|
|
10
|
+
const candidates = (0, lodash_1.flatMap)(Object.values(os_1.default.networkInterfaces()));
|
|
11
|
+
return candidates
|
|
12
|
+
.filter(item => item != null && item.family === 'IPv4')
|
|
13
|
+
.map(item => item.address);
|
|
14
|
+
}
|
|
15
|
+
exports.getLocalhostAddresses = getLocalhostAddresses;
|
|
16
|
+
//# sourceMappingURL=getLocalhostAddresses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLocalhostAddresses.js","sourceRoot":"","sources":["../../../src/webpack/utils/getLocalhostAddresses.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAiC;AACjC,4CAAoB;AAEpB,SAAgB,qBAAqB;IACnC,MAAM,UAAU,GAAG,IAAA,gBAAO,EAAC,MAAM,CAAC,MAAM,CAAC,YAAE,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC;IAClE,OAAO,UAAU;SACd,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC;SACtD,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAK,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC;AALD,sDAKC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parseAlias(tsConfigPath: string, sourcePath: string): Record<string, string>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.parseAlias = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const readJsonFile_1 = require("../../util/readJsonFile");
|
|
9
|
+
function parseAlias(tsConfigPath, sourcePath) {
|
|
10
|
+
var _a;
|
|
11
|
+
const tsConfig = (0, readJsonFile_1.readJsonFile)(tsConfigPath);
|
|
12
|
+
return Object.entries((_a = tsConfig.compilerOptions.paths) !== null && _a !== void 0 ? _a : {})
|
|
13
|
+
.map(([alias, targetPaths]) => [alias.replace('/*', ''), targetPaths[0].replace('/*', '')])
|
|
14
|
+
.map(([key, value]) => [key, path_1.default.resolve(sourcePath, value)])
|
|
15
|
+
.reduce((acc, [key, val]) => (Object.assign(Object.assign({}, acc), { [key]: val })), {});
|
|
16
|
+
}
|
|
17
|
+
exports.parseAlias = parseAlias;
|
|
18
|
+
//# sourceMappingURL=parseAlias.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseAlias.js","sourceRoot":"","sources":["../../../src/webpack/utils/parseAlias.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,0DAAuD;AAQvD,SAAgB,UAAU,CAAC,YAAoB,EAAE,UAAkB;;IACjE,MAAM,QAAQ,GAAqB,IAAA,2BAAY,EAAC,YAAY,CAAC,CAAC;IAC9D,OAAO,MAAM,CAAC,OAAO,CAAC,MAAA,QAAQ,CAAC,eAAe,CAAC,KAAK,mCAAI,EAAE,CAAC;SACxD,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;SAC1F,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,cAAI,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;SAC7D,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,iCAAM,GAAG,KAAE,CAAC,GAAG,CAAC,EAAE,GAAG,IAAG,EAAE,EAAE,CAAC,CAAC;AAC/D,CAAC;AAND,gCAMC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.webpack = void 0;
|
|
7
|
+
// Webpack modules.
|
|
8
|
+
const clean_webpack_plugin_1 = require("clean-webpack-plugin");
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const webpack_1 = require("webpack");
|
|
11
|
+
const webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
|
|
12
|
+
const webpack_merge_1 = __importDefault(require("webpack-merge"));
|
|
13
|
+
const webpackbar_1 = __importDefault(require("webpackbar"));
|
|
14
|
+
const readJsonFile_1 = require("../util/readJsonFile");
|
|
15
|
+
const devServer_1 = require("./options/devServer");
|
|
16
|
+
const environments_1 = require("./options/environments");
|
|
17
|
+
const optimization_1 = require("./options/optimization");
|
|
18
|
+
const rules_1 = require("./options/rules");
|
|
19
|
+
const parseAlias_1 = require("./utils/parseAlias");
|
|
20
|
+
//@ts-ignore
|
|
21
|
+
const circular_dependency_plugin_1 = __importDefault(require("circular-dependency-plugin"));
|
|
22
|
+
const configuration = {
|
|
23
|
+
performance: { hints: false },
|
|
24
|
+
output: { filename: `[name].min.js` },
|
|
25
|
+
plugins: [
|
|
26
|
+
new clean_webpack_plugin_1.CleanWebpackPlugin(),
|
|
27
|
+
new circular_dependency_plugin_1.default({
|
|
28
|
+
exclude: /a\.js|node_modules/,
|
|
29
|
+
failOnError: true,
|
|
30
|
+
allowAsyncCycles: false,
|
|
31
|
+
cwd: process.cwd(),
|
|
32
|
+
}),
|
|
33
|
+
],
|
|
34
|
+
resolve: {
|
|
35
|
+
extensions: [".js", ".ts", ".json"],
|
|
36
|
+
},
|
|
37
|
+
stats: "errors-warnings",
|
|
38
|
+
};
|
|
39
|
+
function createWatchConfiguration(staticPath) {
|
|
40
|
+
return (0, webpack_merge_1.default)(configuration, {
|
|
41
|
+
devtool: "inline-source-map",
|
|
42
|
+
devServer: (0, devServer_1.createDevServerOption)(staticPath),
|
|
43
|
+
watchOptions: { ignored: /node_modules/, poll: true },
|
|
44
|
+
watch: true,
|
|
45
|
+
stats: "errors-only",
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function paresPackageInfo(porjectPath) {
|
|
49
|
+
const { name, version, targetName } = (0, readJsonFile_1.readJsonFile)(path_1.default.resolve(porjectPath, "package.json"));
|
|
50
|
+
const tmpName = targetName !== null && targetName !== void 0 ? targetName : name;
|
|
51
|
+
const pureName = tmpName.substr(tmpName.lastIndexOf("/") + 1);
|
|
52
|
+
return { version, name: pureName };
|
|
53
|
+
}
|
|
54
|
+
function webpack(config) {
|
|
55
|
+
var _a;
|
|
56
|
+
const isProductionMode = ["analyze", "prod"].includes(environments_1.BUILD_MODE !== null && environments_1.BUILD_MODE !== void 0 ? environments_1.BUILD_MODE : "");
|
|
57
|
+
const isHotMode = environments_1.BUILD_MODE === "hot";
|
|
58
|
+
const isAnalyzeMode = environments_1.BUILD_MODE === "analyze";
|
|
59
|
+
const { version, name } = paresPackageInfo(config.path);
|
|
60
|
+
const tsConfigPath = (_a = config.tsconfig) !== null && _a !== void 0 ? _a : path_1.default.resolve(config.path, "tsconfig.json");
|
|
61
|
+
const sourcePath = path_1.default.resolve(config.path, "src");
|
|
62
|
+
const outputPath = path_1.default.resolve(config.path, "dist");
|
|
63
|
+
const alias = (0, parseAlias_1.parseAlias)(tsConfigPath, config.path);
|
|
64
|
+
const analyzePlugins = isAnalyzeMode ? [new webpack_bundle_analyzer_1.BundleAnalyzerPlugin()] : [];
|
|
65
|
+
const baseConfiguration = isHotMode
|
|
66
|
+
? createWatchConfiguration(outputPath)
|
|
67
|
+
: configuration;
|
|
68
|
+
const additionalConfigs = (0, webpack_merge_1.default)(config.webpack, {
|
|
69
|
+
mode: isProductionMode ? "production" : "development",
|
|
70
|
+
resolve: { alias },
|
|
71
|
+
entry: config.webpack.entry || { [name]: `${sourcePath}/index.ts` },
|
|
72
|
+
output: { path: outputPath },
|
|
73
|
+
module: { rules: (0, rules_1.createDefaultRules)(sourcePath) },
|
|
74
|
+
plugins: [
|
|
75
|
+
new webpackbar_1.default({ name }),
|
|
76
|
+
...analyzePlugins,
|
|
77
|
+
new webpack_1.DefinePlugin({
|
|
78
|
+
CA_DEBUG: !isProductionMode,
|
|
79
|
+
CA_VERSION: JSON.stringify(version),
|
|
80
|
+
CA_PRODUCTION: isProductionMode,
|
|
81
|
+
}),
|
|
82
|
+
],
|
|
83
|
+
optimization: isProductionMode ? optimization_1.optimizationOption : undefined,
|
|
84
|
+
});
|
|
85
|
+
return (0, webpack_merge_1.default)(baseConfiguration, additionalConfigs);
|
|
86
|
+
}
|
|
87
|
+
exports.webpack = webpack;
|
|
88
|
+
//# sourceMappingURL=webpack.base.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webpack.base.config.js","sourceRoot":"","sources":["../../src/webpack/webpack.base.config.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boxfoxs/scraping-bundler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"clean": "rm -rf dist && mkdir dist",
|
|
11
11
|
"build": "tsc -p tsconfig.json",
|
|
12
12
|
"fix": "sts fix",
|
|
13
|
-
"deploy": "yarn build &&
|
|
13
|
+
"deploy": "yarn build && npm publish --access=public"
|
|
14
14
|
},
|
|
15
15
|
"bin": {
|
|
16
16
|
"scraping-build": "bin/build.sh"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/node": "^13.11.1",
|
|
20
20
|
"barreler": "^0.0.5",
|
|
21
|
-
"typescript": "^
|
|
21
|
+
"typescript": "^4.6.2"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@babel/cli": "^7.11.6",
|
|
@@ -42,7 +42,6 @@
|
|
|
42
42
|
"@types/shelljs": "^0.8.8",
|
|
43
43
|
"@types/terser-webpack-plugin": "^4.2.0",
|
|
44
44
|
"@types/webpack-bundle-analyzer": "^3.8.0",
|
|
45
|
-
"@types/webpack-dev-server": "^3.11.0",
|
|
46
45
|
"@types/webpack-merge": "^4.1.5",
|
|
47
46
|
"@types/webpackbar": "^4.0.0",
|
|
48
47
|
"babel-loader": "^8.1.0",
|
|
@@ -61,11 +60,11 @@
|
|
|
61
60
|
"terser-webpack-plugin": "^4.2.1",
|
|
62
61
|
"ts-node": "^9.0.0",
|
|
63
62
|
"tsconfig-paths": "^3.9.0",
|
|
64
|
-
"typescript": "^
|
|
63
|
+
"typescript": "^4.6.2",
|
|
65
64
|
"webpack": "^4.44.1",
|
|
66
65
|
"webpack-bundle-analyzer": "^3.8.0",
|
|
67
66
|
"webpack-cli": "^3.3.12",
|
|
68
|
-
"webpack-dev-server": "^
|
|
67
|
+
"webpack-dev-server": "^5.2.2",
|
|
69
68
|
"webpack-merge": "^5.1.4",
|
|
70
69
|
"webpackbar": "^4.0.0"
|
|
71
70
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import helmet from 'helmet';
|
|
2
2
|
import morgan from 'morgan';
|
|
3
|
+
import { Application } from 'express';
|
|
3
4
|
import { Configuration } from 'webpack-dev-server';
|
|
4
5
|
import { getLocalhostAddresses } from '../utils/getLocalhostAddresses';
|
|
5
6
|
|
|
@@ -9,11 +10,13 @@ export function createDevServerOption(staticPath: string): Configuration {
|
|
|
9
10
|
return {
|
|
10
11
|
allowedHosts: localhostNames,
|
|
11
12
|
|
|
12
|
-
before
|
|
13
|
+
// @ts-ignore - webpack-dev-server 4.x supports 'before' but types may not match
|
|
14
|
+
before: (app: Application) => {
|
|
13
15
|
app.use(helmet({ hsts: false }));
|
|
14
16
|
app.use(morgan('dev'));
|
|
15
17
|
},
|
|
16
18
|
|
|
19
|
+
// @ts-ignore - webpack-dev-server 4.x supports 'after' but types may not match
|
|
17
20
|
after: () => {
|
|
18
21
|
console.log('\n\nAvailable on:');
|
|
19
22
|
console.log(`${localhostNames.map(hostname => ` http://${hostname}:10808`).join('\n')}\n`);
|
|
@@ -27,5 +30,5 @@ export function createDevServerOption(staticPath: string): Configuration {
|
|
|
27
30
|
port: 10808,
|
|
28
31
|
writeToDisk: true,
|
|
29
32
|
quiet: true,
|
|
30
|
-
};
|
|
33
|
+
} as Configuration;
|
|
31
34
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import TerserPlugin from 'terser-webpack-plugin';
|
|
2
|
+
import { Configuration } from 'webpack';
|
|
2
3
|
|
|
3
|
-
export const optimizationOption = {
|
|
4
|
+
export const optimizationOption: Configuration['optimization'] = {
|
|
4
5
|
usedExports: true,
|
|
5
6
|
minimizer: [
|
|
6
7
|
new TerserPlugin({
|
|
@@ -15,6 +16,6 @@ export const optimizationOption = {
|
|
|
15
16
|
output: { ecma: 6, beautify: false, safari10: true, comments: false },
|
|
16
17
|
},
|
|
17
18
|
extractComments: false,
|
|
18
|
-
}),
|
|
19
|
+
}) as any,
|
|
19
20
|
],
|
|
20
21
|
};
|
package/tsconfig.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
+
"skipLibCheck": true,
|
|
3
4
|
"target": "es6",
|
|
4
5
|
"declaration": true,
|
|
5
6
|
"outDir": "./dist",
|
|
@@ -14,8 +15,9 @@
|
|
|
14
15
|
"noImplicitAny": true,
|
|
15
16
|
"noUnusedLocals": true,
|
|
16
17
|
"baseUrl": ".",
|
|
17
|
-
"experimentalDecorators": true
|
|
18
|
+
"experimentalDecorators": true,
|
|
19
|
+
"types": []
|
|
18
20
|
},
|
|
19
|
-
"include": ["src"],
|
|
20
|
-
"exclude": ["**/__mocks__/*", "**/__tests__/*", "**/__test__/*"]
|
|
21
|
+
"include": ["src/**/*"],
|
|
22
|
+
"exclude": ["**/__mocks__/*", "**/__tests__/*", "**/__test__/*", "node_modules", "**/node_modules"]
|
|
21
23
|
}
|