@servicetitan/dte-pdf-editor 1.7.0 → 1.8.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/package.json +16 -3
- package/webpack.config.js +0 -112
package/package.json
CHANGED
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/dte-pdf-editor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"typings": "./dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist",
|
|
9
|
-
"src"
|
|
10
|
-
"webpack.config.js"
|
|
9
|
+
"src"
|
|
11
10
|
],
|
|
12
11
|
"publishConfig": {
|
|
13
12
|
"access": "public",
|
|
14
13
|
"registry": "https://registry.npmjs.org"
|
|
15
14
|
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"postbuild": "node copy-css.js",
|
|
17
|
+
"build:webpack": "webpack --mode production",
|
|
18
|
+
"build:webpack:dev": "webpack --mode development"
|
|
19
|
+
},
|
|
16
20
|
"cli": {
|
|
17
21
|
"webpack": false
|
|
18
22
|
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"css-loader": "^7.1.2",
|
|
25
|
+
"css-minimizer-webpack-plugin": "^7.0.0",
|
|
26
|
+
"file-loader": "^6.2.0",
|
|
27
|
+
"mini-css-extract-plugin": "^2.9.0",
|
|
28
|
+
"ts-loader": "^9.5.1",
|
|
29
|
+
"webpack": "^5.102.1",
|
|
30
|
+
"webpack-cli": "^6.0.1"
|
|
31
|
+
},
|
|
19
32
|
"dependencies": {
|
|
20
33
|
"pdfjs-dist": "^3.11.0",
|
|
21
34
|
"react-pdf": "^7.5.0",
|
package/webpack.config.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const webpack = require('webpack');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Returns webpack configuration modifications needed for @servicetitan/dte-pdf-editor
|
|
7
|
-
* This handles CSS resolution issues when the package is consumed.
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
* const { getPdfEditorWebpackConfig } = require('@servicetitan/dte-pdf-editor/webpack.config');
|
|
11
|
-
* const baseConfig = createWebpackConfig({ ... });
|
|
12
|
-
* const pdfEditorConfig = getPdfEditorWebpackConfig(__dirname);
|
|
13
|
-
* // Merge pdfEditorConfig into baseConfig
|
|
14
|
-
*
|
|
15
|
-
* @param {string} consumerDir - The __dirname of the consuming package's webpack config
|
|
16
|
-
* @returns {object} Webpack configuration object with resolve aliases and plugins
|
|
17
|
-
*/
|
|
18
|
-
function getPdfEditorWebpackConfig(consumerDir) {
|
|
19
|
-
const pdfEditorDistStyles = path.resolve(
|
|
20
|
-
consumerDir,
|
|
21
|
-
'../../node_modules/@servicetitan/dte-pdf-editor/dist/styles/index.css',
|
|
22
|
-
);
|
|
23
|
-
const pdfEditorSrcStyles = path.resolve(
|
|
24
|
-
consumerDir,
|
|
25
|
-
'../../node_modules/@servicetitan/dte-pdf-editor/src/styles/index.css',
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
resolve: {
|
|
30
|
-
alias: {
|
|
31
|
-
// Workaround for @servicetitan/dte-pdf-editor CSS resolution
|
|
32
|
-
'@servicetitan/dte-pdf-editor/dist/styles/index.css': fs.existsSync(
|
|
33
|
-
pdfEditorDistStyles,
|
|
34
|
-
)
|
|
35
|
-
? pdfEditorDistStyles
|
|
36
|
-
: pdfEditorSrcStyles,
|
|
37
|
-
// Also alias the dist styles path to source for consistency
|
|
38
|
-
'@servicetitan/dte-pdf-editor/dist/styles': path.resolve(
|
|
39
|
-
consumerDir,
|
|
40
|
-
'../../node_modules/@servicetitan/dte-pdf-editor/src/styles',
|
|
41
|
-
),
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
plugins: [
|
|
45
|
-
// Handle relative CSS imports from compiled pdf-editor code
|
|
46
|
-
new webpack.NormalModuleReplacementPlugin(
|
|
47
|
-
/\.\.\/\.\.\/styles\/index\.css$/,
|
|
48
|
-
resource => {
|
|
49
|
-
if (
|
|
50
|
-
resource.context &&
|
|
51
|
-
(resource.context.includes(
|
|
52
|
-
'@servicetitan/dte-pdf-editor/dist/components',
|
|
53
|
-
) ||
|
|
54
|
-
resource.context.includes('@servicetitan/dte-pdf-editor/dist') ||
|
|
55
|
-
resource.context.includes('dte-pdf-editor'))
|
|
56
|
-
) {
|
|
57
|
-
// Try dist first, fall back to src
|
|
58
|
-
resource.request = fs.existsSync(pdfEditorDistStyles)
|
|
59
|
-
? pdfEditorDistStyles
|
|
60
|
-
: pdfEditorSrcStyles;
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
),
|
|
64
|
-
new webpack.NormalModuleReplacementPlugin(/\.\.\/styles\/index\.css$/, resource => {
|
|
65
|
-
if (
|
|
66
|
-
resource.context &&
|
|
67
|
-
(resource.context.includes('@servicetitan/dte-pdf-editor/dist/components') ||
|
|
68
|
-
resource.context.includes('@servicetitan/dte-pdf-editor/dist') ||
|
|
69
|
-
resource.context.includes('dte-pdf-editor'))
|
|
70
|
-
) {
|
|
71
|
-
// Try dist first, fall back to src
|
|
72
|
-
resource.request = fs.existsSync(pdfEditorDistStyles)
|
|
73
|
-
? pdfEditorDistStyles
|
|
74
|
-
: pdfEditorSrcStyles;
|
|
75
|
-
}
|
|
76
|
-
}),
|
|
77
|
-
],
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Merges pdf-editor webpack config into an existing webpack config
|
|
83
|
-
*
|
|
84
|
-
* @param {object} baseConfig - The base webpack configuration
|
|
85
|
-
* @param {string} consumerDir - The __dirname of the consuming package's webpack config
|
|
86
|
-
* @returns {object} Merged webpack configuration
|
|
87
|
-
*/
|
|
88
|
-
function mergePdfEditorWebpackConfig(baseConfig, consumerDir) {
|
|
89
|
-
const pdfEditorConfig = getPdfEditorWebpackConfig(consumerDir);
|
|
90
|
-
|
|
91
|
-
// Merge resolve aliases
|
|
92
|
-
if (!baseConfig.resolve) {
|
|
93
|
-
baseConfig.resolve = {};
|
|
94
|
-
}
|
|
95
|
-
if (!baseConfig.resolve.alias) {
|
|
96
|
-
baseConfig.resolve.alias = {};
|
|
97
|
-
}
|
|
98
|
-
Object.assign(baseConfig.resolve.alias, pdfEditorConfig.resolve.alias);
|
|
99
|
-
|
|
100
|
-
// Merge plugins
|
|
101
|
-
if (!baseConfig.plugins) {
|
|
102
|
-
baseConfig.plugins = [];
|
|
103
|
-
}
|
|
104
|
-
baseConfig.plugins.push(...pdfEditorConfig.plugins);
|
|
105
|
-
|
|
106
|
-
return baseConfig;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
module.exports = {
|
|
110
|
-
getPdfEditorWebpackConfig,
|
|
111
|
-
mergePdfEditorWebpackConfig,
|
|
112
|
-
};
|