Исправление компиляции, добавление отладки

This commit is contained in:
2024-03-21 19:52:32 +04:00
parent 387b3925c6
commit ca1a01a06e
5 changed files with 107 additions and 32 deletions
+5
View File
@@ -1,4 +1,9 @@
{
"ignorePatterns": [
"node_modules/",
"settings.*.js",
"webpack.*.js"
],
"plugins": ["@typescript-eslint"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "google"],
"parser": "@babel/eslint-parser",
+62 -24
View File
File diff suppressed because one or more lines are too long
+21
View File
@@ -23,3 +23,24 @@ export function getTextNodes(
filter((_, node) => node.nodeType === Node.TEXT_NODE);
}
let debugEnabled = ((scriptElement) => {
if (!(scriptElement instanceof HTMLScriptElement)) {
return false;
}
return !/\.min\.js$/.test(scriptElement.src);
})(document.currentScript);
/**
* Отоброзить отладочное сообщение
*/
export function debug(...data: (string|number|object)[]) {
if (!debugEnabled) return;
console.log(...data);
}
/**
* Включить отладку
*/
export function enableDebug() {
debugEnabled = true;
}
+14 -3
View File
@@ -3,8 +3,9 @@ const webpack = require("webpack");
const BomPlugin = require("webpack-utf8-bom");
const TerserPlugin = require("terser-webpack-plugin");
const { libBanner } = require("./webpack.banner");
const { libUpload } = require("./webpack.upload");
const isProduction = process.env.NODE_ENV == "production";
const isProduction = process.env.NODE_ENV === "production";
const config = {
entry: "./src/main.ts",
@@ -20,9 +21,19 @@ const config = {
module: {
rules: [
{
test: /\.(ts|tsx)$/i,
test: /\.tsx?$/i,
loader: "ts-loader",
exclude: ["/node_modules/"],
exclude: /node_modules|\.d\.ts$/,
// exclude: ["/node_modules/|.d.ts"],
options: {
compilerOptions: {
noEmit: false,
},
},
},
{
test: /\.d\.ts$/i,
loader: 'ignore-loader'
},
{
test: /\.(eot|svg|ttf|woff|woff2|png|jpg|gif)$/i,
+5 -5
View File
@@ -1,16 +1,16 @@
const { exec } = require("node:child_process");
const { exec } = require('node:child_process');
const libUpload = {
apply: (compiler) => {
compiler.hooks.afterEmit.tap("AfterEmitPlugin", (compilation) => {
exec("./upload.sh", (err, stdout, stderr) => {
compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => {
exec('./upload.sh', (err, stdout, stderr) => {
if (stdout) process.stdout.write(stdout);
if (stderr) process.stderr.write(stderr);
console.log("Uploaded.");
console.log('Uploaded.');
});
});
},
}
module.exports
module.exports = { libUpload };