@vixoniccom/module-packager 2.12.1-test.0 → 2.13.0-dev.1

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/dist/main.js CHANGED
@@ -13,6 +13,7 @@ import { Configuration } from '@vixoniccom/modules';
13
13
  import tsNode from 'ts-node';
14
14
  import { createRequire } from 'module';
15
15
  import which from 'which';
16
+ import 'dotenv/config';
16
17
  const __filename = fileURLToPath(import.meta.url);
17
18
  const __dirname = path.dirname(__filename);
18
19
  const electronPath = path.join(__dirname, 'electron.js');
@@ -13,31 +13,39 @@ export default (env = {}, argv = {}) => {
13
13
  port: env.port ?? 8080,
14
14
  mode: argv.mode ?? 'production',
15
15
  };
16
- const isDev = options.mode === 'development' ||
17
- argv.watch === true ||
18
- process.env.NODE_ENV === 'development';
16
+ const isDev = options.mode === 'development' || argv.watch === true || process.env.NODE_ENV === 'development';
19
17
  const buildPath = path.resolve(options.build);
20
18
  const controllerHtmlPath = path.resolve(options.src, 'index.html');
21
19
  const controllerStaticPath = path.resolve(path.dirname(controllerHtmlPath), '../static');
22
20
  const controllerFontsPath = path.resolve(path.dirname(controllerHtmlPath), '../fonts');
23
21
  const controllerTestPath = path.resolve(options.src, 'test');
22
+ // Process all environment variables
23
+ const getEnvironmentVariables = () => {
24
+ const envVars = {};
25
+ Object.keys(process.env).forEach((key) => {
26
+ envVars[`process.env.${key}`] = JSON.stringify(process.env[key]);
27
+ });
28
+ return envVars;
29
+ };
24
30
  return {
25
31
  mode: isDev ? 'development' : 'production',
26
32
  target: options.target ?? 'electron-renderer',
27
- entry: isDev ? [
28
- `webpack-dev-server/client?http://localhost:${options.port}/`,
29
- 'webpack/hot/dev-server',
30
- path.resolve(options.src, 'main.ts')
31
- ] : path.resolve(options.src, 'main.ts'),
33
+ entry: isDev
34
+ ? [
35
+ `webpack-dev-server/client?http://localhost:${options.port}/`,
36
+ 'webpack/hot/dev-server',
37
+ path.resolve(options.src, 'main.ts'),
38
+ ]
39
+ : path.resolve(options.src, 'main.ts'),
32
40
  output: {
33
41
  path: buildPath,
34
42
  filename: '[name].js',
35
- publicPath: isDev ? '/' : './'
43
+ publicPath: isDev ? '/' : './',
36
44
  },
37
45
  performance: {
38
46
  maxAssetSize: 2000000, //2MB
39
47
  maxEntrypointSize: 2000000,
40
- hints: isDev ? false : 'warning'
48
+ hints: isDev ? false : 'warning',
41
49
  },
42
50
  externals: {
43
51
  electron: 'commonjs electron',
@@ -46,7 +54,7 @@ export default (env = {}, argv = {}) => {
46
54
  'terser-webpack-plugin': 'commonjs terser-webpack-plugin',
47
55
  esbuild: 'commonjs esbuild',
48
56
  '@swc/core': 'commonjs @swc/core',
49
- '@swc/wasm': 'commonjs @swc/wasm'
57
+ '@swc/wasm': 'commonjs @swc/wasm',
50
58
  },
51
59
  resolve: {
52
60
  extensions: ['.tsx', '.ts', '.js', '.jsx', '.mjs'],
@@ -54,9 +62,9 @@ export default (env = {}, argv = {}) => {
54
62
  fullySpecified: false,
55
63
  fallback: {
56
64
  process: require.resolve('process/browser.js'),
57
- global: require.resolve('global')
65
+ global: require.resolve('global'),
58
66
  },
59
- modules: ['node_modules', 'src', 'static']
67
+ modules: ['node_modules', 'src', 'static'],
60
68
  },
61
69
  module: {
62
70
  rules: [
@@ -66,25 +74,25 @@ export default (env = {}, argv = {}) => {
66
74
  use: {
67
75
  loader: 'ts-loader',
68
76
  options: {
69
- transpileOnly: true
70
- }
71
- }
77
+ transpileOnly: true,
78
+ },
79
+ },
72
80
  },
73
81
  {
74
82
  test: /\.s[ac]ss$/,
75
- use: ['style-loader', 'css-loader', 'sass-loader']
83
+ use: ['style-loader', 'css-loader', 'sass-loader'],
76
84
  },
77
85
  {
78
86
  test: /\.css$/,
79
87
  use: ['style-loader', 'css-loader'],
80
- exclude: /node_modules/
88
+ exclude: /node_modules/,
81
89
  },
82
90
  {
83
91
  test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|mp4)$/,
84
92
  type: 'asset/resource',
85
93
  generator: {
86
- filename: '[name][ext]'
87
- }
94
+ filename: '[name][ext]',
95
+ },
88
96
  },
89
97
  {
90
98
  test: /\.html$/,
@@ -92,32 +100,33 @@ export default (env = {}, argv = {}) => {
92
100
  loader: 'html-loader',
93
101
  options: {
94
102
  sources: false,
95
- }
96
- }
97
- }
98
- ]
103
+ },
104
+ },
105
+ },
106
+ ],
99
107
  },
100
108
  plugins: [
101
109
  new webpack.DefinePlugin({
102
- global: 'globalThis'
110
+ global: 'globalThis',
111
+ ...getEnvironmentVariables(),
103
112
  }),
104
113
  new webpack.ProvidePlugin({
105
- process: 'process/browser.js'
114
+ process: 'process/browser.js',
106
115
  }),
107
116
  new CleanWebpackPlugin(),
108
117
  new HtmlWebpackPlugin({
109
118
  template: controllerHtmlPath,
110
119
  filename: 'index.html',
111
120
  inject: 'body',
112
- chunks: ['main']
121
+ chunks: ['main'],
113
122
  }),
114
123
  new CopyWebpackPlugin({
115
124
  patterns: [
116
125
  { from: controllerStaticPath, to: 'static', noErrorOnMissing: true },
117
126
  { from: controllerFontsPath, to: 'fonts', noErrorOnMissing: true },
118
- { from: controllerTestPath, to: 'test', noErrorOnMissing: true }
119
- ]
120
- })
127
+ { from: controllerTestPath, to: 'test', noErrorOnMissing: true },
128
+ ],
129
+ }),
121
130
  ],
122
131
  optimization: {
123
132
  minimize: !isDev,
@@ -128,31 +137,33 @@ export default (env = {}, argv = {}) => {
128
137
  ecma: 2020,
129
138
  compress: true,
130
139
  mangle: true,
131
- format: { comments: false }
132
- }
133
- })
134
- ]
140
+ format: { comments: false },
141
+ },
142
+ }),
143
+ ],
135
144
  },
136
145
  devtool: isDev ? 'source-map' : false,
137
- devServer: isDev ? {
138
- static: [
139
- {
140
- directory: path.resolve(options.src, 'test'),
141
- publicPath: '/test',
142
- watch: true,
143
- }
144
- ],
145
- open: false,
146
- client: {
147
- overlay: true
148
- },
149
- port: options.port || 8080,
150
- hot: true,
151
- historyApiFallback: true,
152
- devMiddleware: {
153
- publicPath: '/',
154
- writeToDisk: false
146
+ devServer: isDev
147
+ ? {
148
+ static: [
149
+ {
150
+ directory: path.resolve(options.src, 'test'),
151
+ publicPath: '/test',
152
+ watch: true,
153
+ },
154
+ ],
155
+ open: false,
156
+ client: {
157
+ overlay: true,
158
+ },
159
+ port: options.port || 8080,
160
+ hot: true,
161
+ historyApiFallback: true,
162
+ devMiddleware: {
163
+ publicPath: '/',
164
+ writeToDisk: false,
165
+ },
155
166
  }
156
- } : undefined
167
+ : undefined,
157
168
  };
158
169
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vixoniccom/module-packager",
3
- "version": "2.12.1-test.0",
3
+ "version": "2.13.0-dev.1",
4
4
  "type": "module",
5
5
  "license": "ISC",
6
6
  "bin": {
@@ -34,6 +34,7 @@
34
34
  "copy-webpack-plugin": "^13.0.0",
35
35
  "cpy-cli": "^5.0.0",
36
36
  "css-loader": "^7.1.2",
37
+ "dotenv": "^17.2.1",
37
38
  "electron": "^36.1.0",
38
39
  "electron-debug": "^3.2.0",
39
40
  "global": "^4.4.0",