@cocreate/webpack 1.4.3 → 1.6.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/.github/workflows/automated.yml +23 -10
- package/.github/workflows/manual.yml +1 -2
- package/CHANGELOG.md +22 -0
- package/package.json +40 -4
- package/release.config.js +11 -3
- package/src/index.js +204 -174
- package/src/replace-unicode.js +4 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
name: Automated Workflow
|
|
2
|
+
|
|
2
3
|
on:
|
|
3
4
|
push:
|
|
4
5
|
branches:
|
|
5
6
|
- master
|
|
7
|
+
|
|
6
8
|
jobs:
|
|
7
9
|
about:
|
|
8
10
|
runs-on: ubuntu-latest
|
|
@@ -18,26 +20,37 @@ jobs:
|
|
|
18
20
|
with:
|
|
19
21
|
direction: overwrite-github
|
|
20
22
|
githubToken: "${{ secrets.GITHUB }}"
|
|
23
|
+
|
|
21
24
|
release:
|
|
22
25
|
runs-on: ubuntu-latest
|
|
23
26
|
steps:
|
|
24
27
|
- name: Checkout
|
|
25
28
|
uses: actions/checkout@v4
|
|
29
|
+
with:
|
|
30
|
+
fetch-depth: 0 # Required so semantic-release can trace git tags/history
|
|
31
|
+
|
|
26
32
|
- name: Setup Node.js
|
|
27
33
|
uses: actions/setup-node@v4
|
|
28
34
|
with:
|
|
29
|
-
node-version: 22
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
@semantic-release/changelog
|
|
35
|
+
node-version: 22
|
|
36
|
+
|
|
37
|
+
- name: Install Semantic Release & Plugins
|
|
38
|
+
# Installs semantic-release and its plugins on the runner
|
|
39
|
+
run: |
|
|
40
|
+
npm install -g semantic-release \
|
|
41
|
+
@semantic-release/changelog \
|
|
42
|
+
@semantic-release/npm \
|
|
43
|
+
@semantic-release/github \
|
|
36
44
|
@semantic-release/git
|
|
37
|
-
|
|
45
|
+
|
|
46
|
+
- name: Run Semantic Release (Native)
|
|
47
|
+
id: semantic
|
|
48
|
+
# This will automatically pick up your export default config file in the repository root
|
|
49
|
+
run: npx semantic-release
|
|
38
50
|
env:
|
|
39
|
-
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
|
51
|
+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
|
40
52
|
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
|
|
53
|
+
|
|
41
54
|
outputs:
|
|
42
55
|
new_release_published: "${{ steps.semantic.outputs.new_release_published }}"
|
|
43
|
-
new_release_version: "${{ steps.semantic.outputs.new_release_version }}"
|
|
56
|
+
new_release_version: "${{ steps.semantic.outputs.new_release_version }}"
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
# [1.6.0](https://github.com/CoCreate-app/CoCreate-webpack/compare/v1.5.0...v1.6.0) (2026-07-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* update automated workflow and release configuration for improved semantic release handling ([3ba7b27](https://github.com/CoCreate-app/CoCreate-webpack/commit/3ba7b274d241ecebd50e96723b685808b3444cbb))
|
|
7
|
+
|
|
8
|
+
# [1.5.0](https://github.com/CoCreate-app/CoCreate-webpack/compare/v1.4.3...v1.5.0) (2026-07-11)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* remove devDependencies ([c430e68](https://github.com/CoCreate-app/CoCreate-webpack/commit/c430e685803c28b386d8b899348b04f8019e795a))
|
|
14
|
+
* remove postinstall script and ensure dependencies are correctly listed in package.json ([f851cd7](https://github.com/CoCreate-app/CoCreate-webpack/commit/f851cd764023e56f33c7bd251ea97f1afd14b295))
|
|
15
|
+
* removed post install and add add packages to apprved list ([601dda4](https://github.com/CoCreate-app/CoCreate-webpack/commit/601dda4b5a7503262fc8ac35bd8fc0645e18486c))
|
|
16
|
+
* semantic version handling ([2e79c82](https://github.com/CoCreate-app/CoCreate-webpack/commit/2e79c82340d6e87d6b6dda20c781cbafd01a14fb))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
* update ModuleGenerator to use pluginOptions and improve error handling ([af6db28](https://github.com/CoCreate-app/CoCreate-webpack/commit/af6db28d6f0dde3906b424dea975726ddfcf2101))
|
|
22
|
+
|
|
1
23
|
## [1.4.3](https://github.com/CoCreate-app/CoCreate-webpack/compare/v1.4.2...v1.4.3) (2026-02-04)
|
|
2
24
|
|
|
3
25
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/webpack",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "A Webpack integration tool for CoCreate applications, enabling file watching, automated chunking, lazy loading, and file uploading. It leverages CoCreate.config for streamlined project builds and development workflows.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -23,8 +23,7 @@
|
|
|
23
23
|
"scripts": {
|
|
24
24
|
"start": "npx webpack --config webpack.config.js",
|
|
25
25
|
"build": "npx webpack --mode=production --config webpack.config.js",
|
|
26
|
-
"dev": "npx webpack --config webpack.config.js --watch"
|
|
27
|
-
"postinstall": "node -e \"const { execSync } = require('child_process'); try { execSync('coc --version', { stdio: 'ignore' }); } catch (error) { try { execSync('npm install -g @cocreate/cli', { stdio: 'inherit' }); console.log('Installed \"@cocreate/cli\" globally.'); } catch (error) { console.error('Failed to install \"@cocreate/cli\" globally:', error); } }\""
|
|
26
|
+
"dev": "npx webpack --config webpack.config.js --watch"
|
|
28
27
|
},
|
|
29
28
|
"repository": {
|
|
30
29
|
"type": "git",
|
|
@@ -40,5 +39,42 @@
|
|
|
40
39
|
"type": "GitHub Sponsors ❤",
|
|
41
40
|
"url": "https://github.com/sponsors/CoCreate-app"
|
|
42
41
|
},
|
|
43
|
-
"main": "./src/index.js"
|
|
42
|
+
"main": "./src/index.js",
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@cocreate/cli": "^1.54.2",
|
|
45
|
+
"css-loader": "^7.1.3",
|
|
46
|
+
"esbuild": "^0.25.2",
|
|
47
|
+
"esbuild-loader": "^4.3.0",
|
|
48
|
+
"mini-css-extract-plugin": "^1.4.0",
|
|
49
|
+
"sass": "^1.97.3",
|
|
50
|
+
"sass-loader": "^16.0.7",
|
|
51
|
+
"webpack": "^5.39.1",
|
|
52
|
+
"webpack-bundle-analyzer": "^4.4.0",
|
|
53
|
+
"webpack-cli": "^4.7.2",
|
|
54
|
+
"webpack-log": "^3.0.1",
|
|
55
|
+
"webpack-node-externals": "^3.0.0"
|
|
56
|
+
},
|
|
57
|
+
"allowScripts": {
|
|
58
|
+
"@cocreate/acme@1.3.2": true,
|
|
59
|
+
"@cocreate/actions@1.21.4": true,
|
|
60
|
+
"@cocreate/api@1.22.5": true,
|
|
61
|
+
"@cocreate/config@1.13.4": true,
|
|
62
|
+
"@cocreate/crud-client@1.34.6": true,
|
|
63
|
+
"@cocreate/element-prototype@1.31.4": true,
|
|
64
|
+
"@cocreate/elements@1.42.9": true,
|
|
65
|
+
"@cocreate/filter@1.33.6": true,
|
|
66
|
+
"@cocreate/indexeddb@1.23.4": true,
|
|
67
|
+
"@cocreate/local-storage@1.16.5": true,
|
|
68
|
+
"@cocreate/nginx@1.4.4": true,
|
|
69
|
+
"@cocreate/observer@1.19.0": true,
|
|
70
|
+
"@cocreate/organizations@1.30.1": true,
|
|
71
|
+
"@cocreate/render@1.46.1": true,
|
|
72
|
+
"@cocreate/socket-client@1.40.5": true,
|
|
73
|
+
"@cocreate/utils@1.42.2": true,
|
|
74
|
+
"@cocreate/uuid@1.12.4": true,
|
|
75
|
+
"@cocreate/webpack@1.4.3": true,
|
|
76
|
+
"@parcel/watcher@2.5.6": true,
|
|
77
|
+
"esbuild@0.25.12": true,
|
|
78
|
+
"esbuild@0.28.1": true
|
|
79
|
+
}
|
|
44
80
|
}
|
package/release.config.js
CHANGED
|
@@ -10,12 +10,20 @@ module.exports = {
|
|
|
10
10
|
changelogFile: "CHANGELOG.md",
|
|
11
11
|
},
|
|
12
12
|
],
|
|
13
|
-
"@semantic-release/npm",
|
|
14
|
-
"@semantic-release/github",
|
|
13
|
+
"@semantic-release/npm",
|
|
15
14
|
[
|
|
16
|
-
"@semantic-release/
|
|
15
|
+
"@semantic-release/github",
|
|
17
16
|
{
|
|
17
|
+
successComment: false,
|
|
18
|
+
failTitle: false,
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
[
|
|
22
|
+
"@semantic-release/git",
|
|
23
|
+
{
|
|
24
|
+
// Only stage and commit the changelog and package.json
|
|
18
25
|
assets: ["CHANGELOG.md", "package.json"],
|
|
26
|
+
message: "chore(release): ${nextRelease.version} [skip ci]",
|
|
19
27
|
},
|
|
20
28
|
],
|
|
21
29
|
],
|
package/src/index.js
CHANGED
|
@@ -1,194 +1,224 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Webpack plugins and loaders for the CoCreate ecosystem.
|
|
3
|
+
* Includes module generation, automated file uploading, and symlink management.
|
|
4
|
+
*/
|
|
5
|
+
|
|
2
6
|
const fs = require("fs");
|
|
3
7
|
const path = require("path");
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Import the upload function from CoCreate CLI to handle automated file uploads.
|
|
11
|
+
* This function synchronizes local changes with the CoCreate cloud environment.
|
|
12
|
+
*/
|
|
6
13
|
const upload = require("@cocreate/cli/src/commands/upload.js");
|
|
7
14
|
|
|
8
15
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
16
|
+
* @class ModuleGenerator
|
|
17
|
+
* @description A Webpack plugin that dynamically generates a module entry file
|
|
18
|
+
* (typically `CoCreate.modules.js`) based on a configuration object. It leverages
|
|
19
|
+
* `@cocreate/lazy-loader` for efficient code splitting and dependency management.
|
|
11
20
|
*/
|
|
12
21
|
class ModuleGenerator {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
22
|
+
/**
|
|
23
|
+
* @constructor
|
|
24
|
+
* @param {Object} pluginOptions - The configuration for the plugin.
|
|
25
|
+
* @param {Object} [pluginOptions.config] - Direct CoCreate configuration object.
|
|
26
|
+
* @param {string} [pluginOptions.configPath] - Path to a CoCreate config file.
|
|
27
|
+
*/
|
|
28
|
+
constructor(pluginOptions) {
|
|
29
|
+
/** @type {Object} */
|
|
30
|
+
this.pluginOptions = pluginOptions;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @method apply
|
|
35
|
+
* @description Entry point for the Webpack plugin. Taps into the `beforeCompile` hook.
|
|
36
|
+
* @param {import('webpack').Compiler} compiler - The Webpack compiler instance.
|
|
37
|
+
*/
|
|
38
|
+
apply(compiler) {
|
|
39
|
+
let CoCreateConfig;
|
|
40
|
+
|
|
41
|
+
// Resolve configuration source
|
|
42
|
+
if (typeof this.pluginOptions === "object") {
|
|
43
|
+
CoCreateConfig = this.pluginOptions;
|
|
44
|
+
} else if (this.pluginOptions && this.pluginOptions.configPath) {
|
|
45
|
+
try {
|
|
46
|
+
CoCreateConfig = require(this.pluginOptions.configPath);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error("Error loading CoCreate config file:", error);
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
console.error("ModuleGenerator requires either a 'config' object or 'configPath' string.");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** @type {boolean} Track if modules have already been generated to avoid redundant writes. */
|
|
57
|
+
let modulesGenerated = false;
|
|
58
|
+
|
|
59
|
+
compiler.hooks.beforeCompile.tapAsync(
|
|
60
|
+
"CoCreateLazyloader",
|
|
61
|
+
(params, callback) => {
|
|
62
|
+
if (modulesGenerated) {
|
|
63
|
+
callback();
|
|
64
|
+
} else {
|
|
65
|
+
// Fetch the output path from the root of the config, with a fallback
|
|
66
|
+
const outputPath = this.pluginOptions.moduleOutputPath || "./CoCreate.modules.js";
|
|
67
|
+
let moduleContent = `import { dependency, lazyLoad } from '@cocreate/lazy-loader';\n\n`;
|
|
68
|
+
|
|
69
|
+
// Ensure we are explicitly targeting the 'modules' namespace
|
|
70
|
+
const modulesObj = CoCreateConfig.modules || {};
|
|
71
|
+
|
|
72
|
+
// Generate import statements based on module metadata
|
|
73
|
+
Object.entries(modulesObj).forEach(
|
|
74
|
+
([moduleName, moduleInfo]) => {
|
|
75
|
+
// Skip non-objects
|
|
76
|
+
if (typeof moduleInfo !== "object" || moduleInfo === null) return;
|
|
77
|
+
|
|
78
|
+
// Skip items that do not have an import defined (acts as 'continue' in forEach)
|
|
79
|
+
if (!moduleInfo.import) return;
|
|
80
|
+
|
|
81
|
+
if (moduleInfo.selector) {
|
|
82
|
+
// Logic for lazy-loading based on DOM selectors
|
|
83
|
+
const sanitizedSelector = moduleInfo.selector.replaceAll("'", '"');
|
|
84
|
+
moduleContent += `lazyLoad('${moduleName}', '${sanitizedSelector}', () => import(/*webpackChunkName: "${moduleName}-chunk"*/ '${moduleInfo.import}'));\n`;
|
|
85
|
+
} else {
|
|
86
|
+
// Logic for standard dependencies
|
|
87
|
+
moduleContent += `dependency('${moduleName}', import(/*webpackChunkName: "${moduleName}-chunk"*/ '${moduleInfo.import}'));\n`;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
// Persist the generated module file to disk
|
|
93
|
+
fs.writeFile(outputPath, moduleContent, (err) => {
|
|
94
|
+
if (err) {
|
|
95
|
+
console.error(`Error writing ${outputPath}:`, err);
|
|
96
|
+
callback(err);
|
|
97
|
+
} else {
|
|
98
|
+
modulesGenerated = true;
|
|
99
|
+
console.log(`${outputPath} generated successfully.`);
|
|
100
|
+
callback();
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
}
|
|
88
107
|
}
|
|
89
108
|
|
|
90
109
|
/**
|
|
91
|
-
*
|
|
110
|
+
* @class FileUploader
|
|
111
|
+
* @description Handles automated file uploads to the CoCreate platform,
|
|
112
|
+
* primarily intended for use during Webpack's 'watch' mode to sync local changes.
|
|
92
113
|
*/
|
|
93
114
|
class FileUploader {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
115
|
+
/**
|
|
116
|
+
* @constructor
|
|
117
|
+
* @param {Object} env - Environment variables passed from the Webpack CLI.
|
|
118
|
+
* @param {Object} argv - Command line arguments (used to detect --watch).
|
|
119
|
+
*/
|
|
120
|
+
constructor(env, argv) {
|
|
121
|
+
/** @type {Object} */
|
|
122
|
+
this.env = env;
|
|
123
|
+
/** @type {boolean} Internal state to prevent multiple upload triggers. */
|
|
124
|
+
this.isWatching = false;
|
|
125
|
+
/** @type {boolean} Flag indicating if Webpack is in watch mode. */
|
|
126
|
+
this.isWatch = argv.watch === true;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @method apply
|
|
131
|
+
* @description Hooks into the compilation process to trigger uploads.
|
|
132
|
+
* @param {import('webpack').Compiler} compiler - The Webpack compiler instance.
|
|
133
|
+
*/
|
|
134
|
+
apply(compiler) {
|
|
135
|
+
if (this.isWatch) {
|
|
136
|
+
// Optional: Upload files before the first compilation starts
|
|
137
|
+
if (this.env.beforeCompilation) {
|
|
138
|
+
upload(process.cwd(), ["../", "-w"]);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Upload files after assets are emitted to the output directory
|
|
142
|
+
if (this.env.afterCompilation) {
|
|
143
|
+
compiler.hooks.emit.tapAsync(
|
|
144
|
+
"watchFiles",
|
|
145
|
+
(compilation, callback) => {
|
|
146
|
+
if (!this.isWatching) {
|
|
147
|
+
this.isWatching = true;
|
|
148
|
+
upload(process.cwd(), ["../", "-w"]);
|
|
149
|
+
}
|
|
150
|
+
callback();
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
130
156
|
}
|
|
131
157
|
|
|
132
158
|
/**
|
|
133
|
-
*
|
|
159
|
+
* @class SymlinkCreator
|
|
160
|
+
* @description A utility plugin that creates symbolic links after the build process.
|
|
161
|
+
* This is used to map PWA assets and distribution folders to the project root.
|
|
134
162
|
*/
|
|
135
163
|
class SymlinkCreator {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
fs.symlink(target, destination, option, (err) => {
|
|
184
|
-
if (err) console.log(err);
|
|
185
|
-
else console.log("symlink added: ", target);
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
164
|
+
/**
|
|
165
|
+
* @constructor
|
|
166
|
+
* @param {Object} [options] - Configuration options for symlink behavior.
|
|
167
|
+
*/
|
|
168
|
+
constructor(options) {
|
|
169
|
+
/** @type {Object|undefined} */
|
|
170
|
+
this.options = options;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* @method apply
|
|
175
|
+
* @description Taps into the `afterEmit` hook to create symlinks once files are generated.
|
|
176
|
+
* @param {import('webpack').Compiler} compiler - The Webpack compiler instance.
|
|
177
|
+
*/
|
|
178
|
+
apply(compiler) {
|
|
179
|
+
compiler.hooks.afterEmit.tap("SymlinkPlugin", (compilation) => {
|
|
180
|
+
// Standard symlink mappings for CoCreate PWA structure
|
|
181
|
+
// this.createSymlink("./dist", "../dist", "dir");
|
|
182
|
+
// this.createSymlink("./node_modules/@cocreate/pwa/src/service-worker.js", "../service-worker.js", "file");
|
|
183
|
+
// this.createSymlink("./node_modules/@cocreate/pwa/src/manifest.webmanifest", "../manifest.webmanifest", "file");
|
|
184
|
+
// this.createSymlink("./node_modules/@cocreate/pwa/src/offline.html", "../offline.html", "file");
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* @method createSymlink
|
|
190
|
+
* @description Helper method to safely create a symlink if the target exists and the destination is free.
|
|
191
|
+
* @param {string} target - The source path (relative or absolute).
|
|
192
|
+
* @param {string} destination - The target link path (relative or absolute).
|
|
193
|
+
* @param {string} type - The type of symlink ('file', 'dir', or 'junction').
|
|
194
|
+
*/
|
|
195
|
+
createSymlink(target, destination, type) {
|
|
196
|
+
if (fs.existsSync(target)) {
|
|
197
|
+
const absoluteTarget = path.resolve(target);
|
|
198
|
+
if (!fs.existsSync(destination)) {
|
|
199
|
+
const absoluteDestination = path.resolve(destination);
|
|
200
|
+
fs.symlink(absoluteTarget, absoluteDestination, type, (err) => {
|
|
201
|
+
if (err) {
|
|
202
|
+
console.error(`Failed to create symlink at ${destination}:`, err);
|
|
203
|
+
} else {
|
|
204
|
+
console.log(`Symlink created: ${target} -> ${destination}`);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
191
210
|
}
|
|
192
211
|
|
|
193
|
-
|
|
194
|
-
|
|
212
|
+
/**
|
|
213
|
+
* @exports
|
|
214
|
+
* @property {ModuleGenerator} ModuleGenerator - Dynamic module builder plugin.
|
|
215
|
+
* @property {FileUploader} FileUploader - CLI upload integration plugin.
|
|
216
|
+
* @property {SymlinkCreator} SymlinkCreator - PWA/dist symlink management plugin.
|
|
217
|
+
* @property {string} UnicodeLoader - Absolute path to the unicode replacement loader.
|
|
218
|
+
*/
|
|
219
|
+
module.exports = {
|
|
220
|
+
ModuleGenerator,
|
|
221
|
+
FileUploader,
|
|
222
|
+
SymlinkCreator,
|
|
223
|
+
UnicodeLoader: path.resolve(__dirname, 'replace-unicode.js')
|
|
224
|
+
};
|
package/src/replace-unicode.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
module.exports = function (source) {
|
|
2
|
-
|
|
2
|
+
let modifiedSource = source.replace(/\$'/g, '\\u0024\'');
|
|
3
|
+
// console.log("Modified source code:", modifiedSource);
|
|
4
|
+
return modifiedSource;
|
|
3
5
|
|
|
6
|
+
|
|
4
7
|
// const specialChars = /[\0\x08\x09\x1a\n\r"'\\\%\$]/g; // Add or remove characters based on your needs
|
|
5
8
|
// const replacements = {
|
|
6
9
|
// // "\0": "\\0",
|