innetjs 2.0.7 → 2.0.10

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/bin/innet CHANGED
@@ -175,11 +175,11 @@ function getFile(file) {
175
175
  }
176
176
  return file;
177
177
  }
178
- function convertIndexFile(data, version) {
178
+ function convertIndexFile(data, version, baseUrl) {
179
179
  return __awaiter(this, void 0, void 0, function* () {
180
180
  return data
181
181
  .toString()
182
- .replace('</head>', `<script type="module" defer src="index.js${version ? `?v=${version}` : ''}"></script></head>`);
182
+ .replace('</head>', `<script type="module" defer src="${baseUrl}index.js${version ? `?v=${version}` : ''}"></script></head>`);
183
183
  });
184
184
  }
185
185
  const reporter = (options, outputOptions, info) => {
@@ -201,7 +201,7 @@ const innetEnv = Object.keys(process.env).reduce((result, key) => {
201
201
  return result;
202
202
  }, {});
203
203
  class InnetJS {
204
- constructor({ projectFolder = process.env.PROJECT_FOLDER || '', publicFolder = process.env.PUBLIC_FOLDER || 'public', buildFolder = process.env.BUILD_FOLDER || 'build', srcFolder = process.env.SRC_FOLDER || 'src', sourcemap = process.env.SOURCEMAP ? process.env.SOURCEMAP === 'true' : false, cssModules = process.env.CSS_MODULES ? process.env.CSS_MODULES === 'true' : true, cssInJs = process.env.CSS_IN_JS ? process.env.CSS_IN_JS === 'true' : true, sslKey = process.env.SSL_KEY || 'localhost.key', sslCrt = process.env.SSL_CRT || 'localhost.crt', proxy = process.env.PROXY || '', port = process.env.PORT ? +process.env.PORT : 3000, api = process.env.API || '/api/?*', } = {}) {
204
+ constructor({ projectFolder = process.env.PROJECT_FOLDER || '', baseUrl = process.env.BASE_URL || '/', publicFolder = process.env.PUBLIC_FOLDER || 'public', buildFolder = process.env.BUILD_FOLDER || 'build', srcFolder = process.env.SRC_FOLDER || 'src', sourcemap = process.env.SOURCEMAP ? process.env.SOURCEMAP === 'true' : false, cssModules = process.env.CSS_MODULES ? process.env.CSS_MODULES === 'true' : true, cssInJs = process.env.CSS_IN_JS ? process.env.CSS_IN_JS === 'true' : true, sslKey = process.env.SSL_KEY || 'localhost.key', sslCrt = process.env.SSL_CRT || 'localhost.crt', proxy = process.env.PROXY || '', port = process.env.PORT ? +process.env.PORT : 3000, api = process.env.API || '/api/?*', } = {}) {
205
205
  this.projectFolder = path__default["default"].resolve(projectFolder);
206
206
  this.publicFolder = path__default["default"].resolve(publicFolder);
207
207
  this.buildFolder = path__default["default"].resolve(buildFolder);
@@ -218,6 +218,7 @@ class InnetJS {
218
218
  this.port = port;
219
219
  this.proxy = proxy;
220
220
  this.api = api;
221
+ this.baseUrl = baseUrl;
221
222
  }
222
223
  // Methods
223
224
  init(appName, { template, force = false } = {}) {
@@ -302,7 +303,9 @@ class InnetJS {
302
303
  include: lintIncludeDom,
303
304
  }),
304
305
  ...inputOptions.plugins,
305
- pluginNodeResolve.nodeResolve(),
306
+ pluginNodeResolve.nodeResolve({
307
+ browser: true,
308
+ }),
306
309
  image__default["default"](),
307
310
  styles__default["default"]({
308
311
  mode: this.cssInJs ? 'inject' : 'extract',
@@ -334,7 +337,7 @@ class InnetJS {
334
337
  yield copyFiles(this.publicFolder, this.buildFolder);
335
338
  const data = yield fs.promises.readFile(this.publicIndexFile);
336
339
  const pkg = yield this.getPackage();
337
- yield fs.promises.writeFile(this.buildIndexFile, yield convertIndexFile(data, pkg.version));
340
+ yield fs.promises.writeFile(this.buildIndexFile, yield convertIndexFile(data, pkg.version, this.baseUrl));
338
341
  }
339
342
  }));
340
343
  if (pkg) {
@@ -363,7 +366,7 @@ class InnetJS {
363
366
  preserveEntrySignatures: 'strict',
364
367
  output: {
365
368
  dir: this.devBuildFolder,
366
- sourcemap: true
369
+ sourcemap: true,
367
370
  },
368
371
  plugins: [
369
372
  commonjs__default["default"](),
@@ -405,7 +408,9 @@ class InnetJS {
405
408
  include: lintIncludeDom,
406
409
  }),
407
410
  ...options.plugins,
408
- pluginNodeResolve.nodeResolve(),
411
+ pluginNodeResolve.nodeResolve({
412
+ browser: true,
413
+ }),
409
414
  image__default["default"](),
410
415
  styles__default["default"]({
411
416
  mode: this.cssInJs ? 'inject' : 'extract',
@@ -552,7 +557,7 @@ class InnetJS {
552
557
  app = express__default["default"]();
553
558
  const update = () => __awaiter(this, void 0, void 0, function* () {
554
559
  const data = yield fs.promises.readFile(this.publicIndexFile);
555
- yield fs.promises.writeFile(this.devBuildIndexFile, yield convertIndexFile(data, pkg.version));
560
+ yield fs.promises.writeFile(this.devBuildIndexFile, yield convertIndexFile(data, pkg.version, this.baseUrl));
556
561
  });
557
562
  fs__default["default"].watch(this.publicIndexFile, update);
558
563
  yield update();
@@ -565,7 +570,7 @@ class InnetJS {
565
570
  proxyReqPathResolver: req => req.originalUrl
566
571
  }));
567
572
  }
568
- app.use(/^[^.]+$/, (req, res) => {
573
+ app.use(/^([^.]*|.*\.[^.]{5,})$/, (req, res) => {
569
574
  res.sendFile(this.devBuildFolder + '/index.html');
570
575
  });
571
576
  const server = httpsUsing ? https__default["default"].createServer({ key, cert }, app) : http__default["default"].createServer(app);
@@ -611,7 +616,7 @@ class InnetJS {
611
616
  }
612
617
  }
613
618
 
614
- var version = "2.0.7";
619
+ var version = "2.0.10";
615
620
 
616
621
  require('dotenv').config();
617
622
  const innetJS = new InnetJS();
package/helpers.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
2
  import { FileSizeRender } from 'rollup-plugin-filesize';
3
3
  export declare function getFile(file: any): any;
4
- export declare function convertIndexFile(data: Buffer, version: string): Promise<string>;
4
+ export declare function convertIndexFile(data: Buffer, version: string, baseUrl: string): Promise<string>;
5
5
  export declare const reporter: FileSizeRender<string | Promise<string>>;
package/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  declare type Extensions = 'js' | 'ts' | 'tsx' | 'jsx';
2
2
  export default class InnetJS {
3
+ baseUrl: string;
3
4
  projectFolder: string;
4
5
  publicFolder: string;
5
6
  buildFolder: string;
@@ -18,8 +19,9 @@ export default class InnetJS {
18
19
  api: string;
19
20
  private projectExtension;
20
21
  private package;
21
- constructor({ projectFolder, publicFolder, buildFolder, srcFolder, sourcemap, cssModules, cssInJs, sslKey, sslCrt, proxy, port, api, }?: {
22
+ constructor({ projectFolder, baseUrl, publicFolder, buildFolder, srcFolder, sourcemap, cssModules, cssInJs, sslKey, sslCrt, proxy, port, api, }?: {
22
23
  projectFolder?: string;
24
+ baseUrl?: string;
23
25
  publicFolder?: string;
24
26
  buildFolder?: string;
25
27
  srcFolder?: string;
package/index.es6.js CHANGED
@@ -145,11 +145,11 @@ function getFile(file) {
145
145
  }
146
146
  return file;
147
147
  }
148
- function convertIndexFile(data, version) {
148
+ function convertIndexFile(data, version, baseUrl) {
149
149
  return __awaiter(this, void 0, void 0, function* () {
150
150
  return data
151
151
  .toString()
152
- .replace('</head>', `<script type="module" defer src="index.js${version ? `?v=${version}` : ''}"></script></head>`);
152
+ .replace('</head>', `<script type="module" defer src="${baseUrl}index.js${version ? `?v=${version}` : ''}"></script></head>`);
153
153
  });
154
154
  }
155
155
  const reporter = (options, outputOptions, info) => {
@@ -171,7 +171,7 @@ const innetEnv = Object.keys(process.env).reduce((result, key) => {
171
171
  return result;
172
172
  }, {});
173
173
  class InnetJS {
174
- constructor({ projectFolder = process.env.PROJECT_FOLDER || '', publicFolder = process.env.PUBLIC_FOLDER || 'public', buildFolder = process.env.BUILD_FOLDER || 'build', srcFolder = process.env.SRC_FOLDER || 'src', sourcemap = process.env.SOURCEMAP ? process.env.SOURCEMAP === 'true' : false, cssModules = process.env.CSS_MODULES ? process.env.CSS_MODULES === 'true' : true, cssInJs = process.env.CSS_IN_JS ? process.env.CSS_IN_JS === 'true' : true, sslKey = process.env.SSL_KEY || 'localhost.key', sslCrt = process.env.SSL_CRT || 'localhost.crt', proxy = process.env.PROXY || '', port = process.env.PORT ? +process.env.PORT : 3000, api = process.env.API || '/api/?*', } = {}) {
174
+ constructor({ projectFolder = process.env.PROJECT_FOLDER || '', baseUrl = process.env.BASE_URL || '/', publicFolder = process.env.PUBLIC_FOLDER || 'public', buildFolder = process.env.BUILD_FOLDER || 'build', srcFolder = process.env.SRC_FOLDER || 'src', sourcemap = process.env.SOURCEMAP ? process.env.SOURCEMAP === 'true' : false, cssModules = process.env.CSS_MODULES ? process.env.CSS_MODULES === 'true' : true, cssInJs = process.env.CSS_IN_JS ? process.env.CSS_IN_JS === 'true' : true, sslKey = process.env.SSL_KEY || 'localhost.key', sslCrt = process.env.SSL_CRT || 'localhost.crt', proxy = process.env.PROXY || '', port = process.env.PORT ? +process.env.PORT : 3000, api = process.env.API || '/api/?*', } = {}) {
175
175
  this.projectFolder = path$1.resolve(projectFolder);
176
176
  this.publicFolder = path$1.resolve(publicFolder);
177
177
  this.buildFolder = path$1.resolve(buildFolder);
@@ -188,6 +188,7 @@ class InnetJS {
188
188
  this.port = port;
189
189
  this.proxy = proxy;
190
190
  this.api = api;
191
+ this.baseUrl = baseUrl;
191
192
  }
192
193
  // Methods
193
194
  init(appName, { template, force = false } = {}) {
@@ -272,7 +273,9 @@ class InnetJS {
272
273
  include: lintIncludeDom,
273
274
  }),
274
275
  ...inputOptions.plugins,
275
- nodeResolve(),
276
+ nodeResolve({
277
+ browser: true,
278
+ }),
276
279
  image(),
277
280
  styles({
278
281
  mode: this.cssInJs ? 'inject' : 'extract',
@@ -304,7 +307,7 @@ class InnetJS {
304
307
  yield copyFiles(this.publicFolder, this.buildFolder);
305
308
  const data = yield promises.readFile(this.publicIndexFile);
306
309
  const pkg = yield this.getPackage();
307
- yield promises.writeFile(this.buildIndexFile, yield convertIndexFile(data, pkg.version));
310
+ yield promises.writeFile(this.buildIndexFile, yield convertIndexFile(data, pkg.version, this.baseUrl));
308
311
  }
309
312
  }));
310
313
  if (pkg) {
@@ -333,7 +336,7 @@ class InnetJS {
333
336
  preserveEntrySignatures: 'strict',
334
337
  output: {
335
338
  dir: this.devBuildFolder,
336
- sourcemap: true
339
+ sourcemap: true,
337
340
  },
338
341
  plugins: [
339
342
  commonjs(),
@@ -375,7 +378,9 @@ class InnetJS {
375
378
  include: lintIncludeDom,
376
379
  }),
377
380
  ...options.plugins,
378
- nodeResolve(),
381
+ nodeResolve({
382
+ browser: true,
383
+ }),
379
384
  image(),
380
385
  styles({
381
386
  mode: this.cssInJs ? 'inject' : 'extract',
@@ -522,7 +527,7 @@ class InnetJS {
522
527
  app = express();
523
528
  const update = () => __awaiter(this, void 0, void 0, function* () {
524
529
  const data = yield promises.readFile(this.publicIndexFile);
525
- yield promises.writeFile(this.devBuildIndexFile, yield convertIndexFile(data, pkg.version));
530
+ yield promises.writeFile(this.devBuildIndexFile, yield convertIndexFile(data, pkg.version, this.baseUrl));
526
531
  });
527
532
  fs.watch(this.publicIndexFile, update);
528
533
  yield update();
@@ -535,7 +540,7 @@ class InnetJS {
535
540
  proxyReqPathResolver: req => req.originalUrl
536
541
  }));
537
542
  }
538
- app.use(/^[^.]+$/, (req, res) => {
543
+ app.use(/^([^.]*|.*\.[^.]{5,})$/, (req, res) => {
539
544
  res.sendFile(this.devBuildFolder + '/index.html');
540
545
  });
541
546
  const server = httpsUsing ? https.createServer({ key, cert }, app) : http.createServer(app);
package/index.js CHANGED
@@ -173,11 +173,11 @@ function getFile(file) {
173
173
  }
174
174
  return file;
175
175
  }
176
- function convertIndexFile(data, version) {
176
+ function convertIndexFile(data, version, baseUrl) {
177
177
  return __awaiter(this, void 0, void 0, function* () {
178
178
  return data
179
179
  .toString()
180
- .replace('</head>', `<script type="module" defer src="index.js${version ? `?v=${version}` : ''}"></script></head>`);
180
+ .replace('</head>', `<script type="module" defer src="${baseUrl}index.js${version ? `?v=${version}` : ''}"></script></head>`);
181
181
  });
182
182
  }
183
183
  const reporter = (options, outputOptions, info) => {
@@ -199,7 +199,7 @@ const innetEnv = Object.keys(process.env).reduce((result, key) => {
199
199
  return result;
200
200
  }, {});
201
201
  class InnetJS {
202
- constructor({ projectFolder = process.env.PROJECT_FOLDER || '', publicFolder = process.env.PUBLIC_FOLDER || 'public', buildFolder = process.env.BUILD_FOLDER || 'build', srcFolder = process.env.SRC_FOLDER || 'src', sourcemap = process.env.SOURCEMAP ? process.env.SOURCEMAP === 'true' : false, cssModules = process.env.CSS_MODULES ? process.env.CSS_MODULES === 'true' : true, cssInJs = process.env.CSS_IN_JS ? process.env.CSS_IN_JS === 'true' : true, sslKey = process.env.SSL_KEY || 'localhost.key', sslCrt = process.env.SSL_CRT || 'localhost.crt', proxy = process.env.PROXY || '', port = process.env.PORT ? +process.env.PORT : 3000, api = process.env.API || '/api/?*', } = {}) {
202
+ constructor({ projectFolder = process.env.PROJECT_FOLDER || '', baseUrl = process.env.BASE_URL || '/', publicFolder = process.env.PUBLIC_FOLDER || 'public', buildFolder = process.env.BUILD_FOLDER || 'build', srcFolder = process.env.SRC_FOLDER || 'src', sourcemap = process.env.SOURCEMAP ? process.env.SOURCEMAP === 'true' : false, cssModules = process.env.CSS_MODULES ? process.env.CSS_MODULES === 'true' : true, cssInJs = process.env.CSS_IN_JS ? process.env.CSS_IN_JS === 'true' : true, sslKey = process.env.SSL_KEY || 'localhost.key', sslCrt = process.env.SSL_CRT || 'localhost.crt', proxy = process.env.PROXY || '', port = process.env.PORT ? +process.env.PORT : 3000, api = process.env.API || '/api/?*', } = {}) {
203
203
  this.projectFolder = path__default["default"].resolve(projectFolder);
204
204
  this.publicFolder = path__default["default"].resolve(publicFolder);
205
205
  this.buildFolder = path__default["default"].resolve(buildFolder);
@@ -216,6 +216,7 @@ class InnetJS {
216
216
  this.port = port;
217
217
  this.proxy = proxy;
218
218
  this.api = api;
219
+ this.baseUrl = baseUrl;
219
220
  }
220
221
  // Methods
221
222
  init(appName, { template, force = false } = {}) {
@@ -300,7 +301,9 @@ class InnetJS {
300
301
  include: lintIncludeDom,
301
302
  }),
302
303
  ...inputOptions.plugins,
303
- pluginNodeResolve.nodeResolve(),
304
+ pluginNodeResolve.nodeResolve({
305
+ browser: true,
306
+ }),
304
307
  image__default["default"](),
305
308
  styles__default["default"]({
306
309
  mode: this.cssInJs ? 'inject' : 'extract',
@@ -332,7 +335,7 @@ class InnetJS {
332
335
  yield copyFiles(this.publicFolder, this.buildFolder);
333
336
  const data = yield fs.promises.readFile(this.publicIndexFile);
334
337
  const pkg = yield this.getPackage();
335
- yield fs.promises.writeFile(this.buildIndexFile, yield convertIndexFile(data, pkg.version));
338
+ yield fs.promises.writeFile(this.buildIndexFile, yield convertIndexFile(data, pkg.version, this.baseUrl));
336
339
  }
337
340
  }));
338
341
  if (pkg) {
@@ -361,7 +364,7 @@ class InnetJS {
361
364
  preserveEntrySignatures: 'strict',
362
365
  output: {
363
366
  dir: this.devBuildFolder,
364
- sourcemap: true
367
+ sourcemap: true,
365
368
  },
366
369
  plugins: [
367
370
  commonjs__default["default"](),
@@ -403,7 +406,9 @@ class InnetJS {
403
406
  include: lintIncludeDom,
404
407
  }),
405
408
  ...options.plugins,
406
- pluginNodeResolve.nodeResolve(),
409
+ pluginNodeResolve.nodeResolve({
410
+ browser: true,
411
+ }),
407
412
  image__default["default"](),
408
413
  styles__default["default"]({
409
414
  mode: this.cssInJs ? 'inject' : 'extract',
@@ -550,7 +555,7 @@ class InnetJS {
550
555
  app = express__default["default"]();
551
556
  const update = () => __awaiter(this, void 0, void 0, function* () {
552
557
  const data = yield fs.promises.readFile(this.publicIndexFile);
553
- yield fs.promises.writeFile(this.devBuildIndexFile, yield convertIndexFile(data, pkg.version));
558
+ yield fs.promises.writeFile(this.devBuildIndexFile, yield convertIndexFile(data, pkg.version, this.baseUrl));
554
559
  });
555
560
  fs__default["default"].watch(this.publicIndexFile, update);
556
561
  yield update();
@@ -563,7 +568,7 @@ class InnetJS {
563
568
  proxyReqPathResolver: req => req.originalUrl
564
569
  }));
565
570
  }
566
- app.use(/^[^.]+$/, (req, res) => {
571
+ app.use(/^([^.]*|.*\.[^.]{5,})$/, (req, res) => {
567
572
  res.sendFile(this.devBuildFolder + '/index.html');
568
573
  });
569
574
  const server = httpsUsing ? https__default["default"].createServer({ key, cert }, app) : http__default["default"].createServer(app);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "innetjs",
3
- "version": "2.0.7",
3
+ "version": "2.0.10",
4
4
  "description": "CLI for innet boilerplate",
5
5
  "homepage": "https://github.com/d8corp/innetjs",
6
6
  "author": "Mikhail Lysikov <d8corp@mail.ru>",