@cocreate/webpack 1.0.0 → 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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [1.1.0](https://github.com/CoCreate-app/CoCreate-webpack/compare/v1.0.1...v1.1.0) (2023-12-28)
2
+
3
+
4
+ ### Features
5
+
6
+ * symlinkCreator ([b38a089](https://github.com/CoCreate-app/CoCreate-webpack/commit/b38a0892b3755bf83844cbf2b17264c25d5623dc))
7
+
8
+ ## [1.0.1](https://github.com/CoCreate-app/CoCreate-webpack/compare/v1.0.0...v1.0.1) (2023-12-28)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * removed webpack.config ([4d3b7de](https://github.com/CoCreate-app/CoCreate-webpack/commit/4d3b7def7b59c0736cbf9b2dbb3e40585486cf92))
14
+
1
15
  # 1.0.0 (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.0",
3
+ "version": "1.1.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 };
package/webpack.config.js DELETED
@@ -1,84 +0,0 @@
1
- const path = require("path")
2
- const TerserPlugin = require("terser-webpack-plugin")
3
- const MiniCssExtractPlugin = require("mini-css-extract-plugin")
4
- let isProduction = process.env.NODE_ENV === "production"
5
- const { CleanWebpackPlugin } = require("clean-webpack-plugin")
6
-
7
- module.exports = {
8
- entry: {
9
- "CoCreate-webpack": "./src/index.js",
10
- },
11
- output: {
12
- path: path.resolve(__dirname, "dist"),
13
- filename: isProduction ? "[name].min.js" : "[name].js",
14
- libraryTarget: "umd",
15
- libraryExport: "default",
16
- library: ["CoCreate", "webpack"],
17
- globalObject: "this",
18
- },
19
-
20
- plugins: [
21
- new CleanWebpackPlugin(),
22
- new MiniCssExtractPlugin({
23
- filename: "[name].css",
24
- }),
25
- ],
26
- // Default mode for Webpack is production.
27
- // Depending on mode Webpack will apply different things
28
- // on final bundle. For now we don't need production's JavaScript
29
- // minifying and other thing so let's set mode to development
30
- mode: isProduction ? "production" : "development",
31
- module: {
32
- rules: [
33
- {
34
- test: /.js$/,
35
- exclude: /(node_modules)/,
36
- use: {
37
- loader: "babel-loader",
38
- options: {
39
- plugins: ["@babel/plugin-transform-modules-commonjs"],
40
- },
41
- },
42
- },
43
- {
44
- test: /.css$/i,
45
- use: [
46
- { loader: "style-loader", options: { injectType: "linkTag" } },
47
- "file-loader",
48
- ],
49
- },
50
- ],
51
- },
52
-
53
- // add source map
54
- ...(isProduction ? {} : { devtool: "eval-source-map" }),
55
-
56
- optimization: {
57
- minimize: true,
58
- minimizer: [
59
- new TerserPlugin({
60
- extractComments: true,
61
- // cache: true,
62
- parallel: true,
63
- // sourceMap: true, // Must be set to true if using source-maps in production
64
- terserOptions: {
65
- // https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
66
- // extractComments: 'all',
67
- compress: {
68
- drop_console: true,
69
- },
70
- },
71
- }),
72
- ],
73
- splitChunks: {
74
- chunks: "all",
75
- minSize: 200,
76
- // maxSize: 99999,
77
- //minChunks: 1,
78
-
79
- cacheGroups: {
80
- defaultVendors: false,
81
- },
82
- },
83
- },
84
- }