@cocreate/webpack 1.0.1 → 1.2.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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [1.2.0](https://github.com/CoCreate-app/CoCreate-webpack/compare/v1.1.0...v1.2.0) (2023-12-28)
2
+
3
+
4
+ ### Features
5
+
6
+ * symlinkCreator ([5697054](https://github.com/CoCreate-app/CoCreate-webpack/commit/5697054b547e3a9217c7563f4aca64429db3450b))
7
+
8
+ # [1.1.0](https://github.com/CoCreate-app/CoCreate-webpack/compare/v1.0.1...v1.1.0) (2023-12-28)
9
+
10
+
11
+ ### Features
12
+
13
+ * symlinkCreator ([b38a089](https://github.com/CoCreate-app/CoCreate-webpack/commit/b38a0892b3755bf83844cbf2b17264c25d5623dc))
14
+
1
15
  ## [1.0.1](https://github.com/CoCreate-app/CoCreate-webpack/compare/v1.0.0...v1.0.1) (2023-12-28)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/webpack",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "description": "An intergration with webpack and CoCreateJS.",
5
5
  "keywords": [
6
6
  "webpack",
package/src/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  const fs = require('fs');
2
+ const path = require('path');
3
+
2
4
  const upload = require('@cocreate/cli/src/commands/upload.js')
3
5
 
4
6
  class ModuleGenerator {
@@ -54,6 +56,7 @@ class ModuleGenerator {
54
56
  });
55
57
  }
56
58
  }
59
+
57
60
  class fileUploader {
58
61
  constructor(env) {
59
62
  this.env = env;
@@ -78,5 +81,39 @@ class fileUploader {
78
81
  }
79
82
  }
80
83
 
84
+ class SymlinkCreator {
85
+ constructor(options) {
86
+ // Store options if necessary, or just hard-code paths
87
+ }
88
+
89
+ apply(compiler) {
90
+ // Use compiler.hooks to tap into the Webpack build process
91
+ compiler.hooks.afterEmit.tap('SymlinkPlugin', (compilation) => {
92
+ // Perform symlink operations here
93
+ symlink('./dist', '../dist', 'dir');
94
+ symlink('./node_modules/@cocreate/pwa/src/service-worker.js', '../service-worker.js', 'file');
95
+ symlink('./node_modules/@cocreate/pwa/src/manifest.webmanifest', '../manifest.webmanifest', 'file');
96
+ symlink('./node_modules/@cocreate/pwa/src/offline.html', '../offline.html', 'file');
97
+ });
98
+
99
+ function symlink(target, destination, option) {
100
+ if (fs.existsSync(target)) {
101
+ target = path.resolve(target)
102
+
103
+ if (!fs.existsSync(destination)) {
104
+ destination = path.resolve(destination)
105
+
106
+ fs.symlink(target, destination, option, (err) => {
107
+ if (err)
108
+ console.log(err);
109
+ else
110
+ console.log("symlink added: ", target);
111
+ })
112
+
113
+ }
114
+ }
115
+ }
116
+ }
117
+ }
81
118
 
82
- module.exports = { ModuleGenerator, fileUploader };
119
+ module.exports = { ModuleGenerator, fileUploader, SymlinkCreator };