@best-shot/dev-server 0.12.6 → 0.13.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/README.md CHANGED
@@ -35,17 +35,15 @@ npx --no-install best-shot serve [options]
35
35
  ```mjs
36
36
  // example: .best-shot/config.mjs
37
37
  export default {
38
- presets: [
39
- // without this will fallback to `watch` mode
40
- 'serve'
41
- ],
38
+ experiments: {
39
+ lazyCompilation: false // true by default
40
+ },
42
41
  devServer: {
43
- // ...
42
+ // without this will fallback to `watch` mode
44
43
  }
45
44
  };
46
45
  ```
47
46
 
48
47
  ## Related
49
48
 
50
- - [@best-shot/preset-serve](../preset-serve)
51
49
  - [@best-shot/cli](../cli)
package/lib/action.mjs CHANGED
@@ -15,12 +15,15 @@ export function action({ _: [command] }) {
15
15
 
16
16
  const configs = await readConfig()({ command });
17
17
 
18
- const result = configs.map((config) =>
19
- createConfig(config, {
18
+ const result = [];
19
+ for (const config of configs) {
20
+ const io = await createConfig(config, {
20
21
  watch: true,
22
+ serve: Boolean(config.devServer),
21
23
  command,
22
- }),
23
- );
24
+ });
25
+ result.push(io);
26
+ }
24
27
 
25
28
  const shouldServe = [];
26
29
  const shouldWatch = [];
package/lib/server.mjs CHANGED
@@ -7,20 +7,15 @@ import { notFound } from '../middleware/not-found/index.mjs';
7
7
  import * as waitPage from '../middleware/wait-page/index.mjs';
8
8
 
9
9
  class BestShotDevServer extends WebpackDevServer {
10
- // https://github.com/webpack/webpack-dev-server/blob/fd2a4e3ea78d877e9a4a7cdf343ef71e55f0cc57/lib/Server.js#L846
10
+ // https://github.com/webpack/webpack-dev-server/blob/79a169baa3eeaf71df068de5d9c6150684dfe35f/lib/Server.js#L1556
11
11
  setupHistoryApiFallbackFeature() {
12
- const requireLazy = createRequire(import.meta.url);
13
- const historyApiFallback = requireLazy('connect-history-api-fallback');
14
-
15
- const options =
16
- typeof this.options.historyApiFallback !== 'boolean'
17
- ? this.options.historyApiFallback
18
- : {};
12
+ const { historyApiFallback } = this.options;
19
13
 
20
- let logger;
21
-
22
- if (typeof options.verbose === 'undefined') {
23
- logger = this.logger.log.bind(
14
+ if (
15
+ typeof historyApiFallback.logger === 'undefined' &&
16
+ !historyApiFallback.verbose
17
+ ) {
18
+ historyApiFallback.logger = this.logger.log.bind(
24
19
  this.logger,
25
20
  '[connect-history-api-fallback]',
26
21
  );
@@ -32,10 +27,15 @@ class BestShotDevServer extends WebpackDevServer {
32
27
  } = {},
33
28
  } = this.options;
34
29
 
30
+ const requireLazy = createRequire(import.meta.url);
31
+ const connectHistoryApiFallback = requireLazy(
32
+ 'connect-history-api-fallback',
33
+ );
34
+
35
35
  if (publicPath.startsWith('/')) {
36
- this.app.use(publicPath, historyApiFallback({ logger, ...options }));
36
+ this.app.use(publicPath, connectHistoryApiFallback(historyApiFallback));
37
37
  } else {
38
- this.app.use(historyApiFallback({ logger, ...options }));
38
+ this.app.use(connectHistoryApiFallback(historyApiFallback));
39
39
  }
40
40
  }
41
41
  }
@@ -50,6 +50,15 @@ export function DevServer(
50
50
 
51
51
  const publicPath = options.publicPath || compiler.options.output.publicPath;
52
52
 
53
+ /* eslint-disable no-param-reassign */
54
+ if (options.hot === undefined) {
55
+ options.hot = 'only';
56
+ }
57
+ if (options.static === undefined) {
58
+ options.static = false;
59
+ }
60
+ /* eslint-enable no-param-reassign */
61
+
53
62
  const Server = new BestShotDevServer(
54
63
  {
55
64
  ...options,
@@ -2,20 +2,19 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
- <meta name="renderer" content="webkit" />
5
+ <meta content="IE=edge" http-equiv="X-UA-Compatible" />
6
+ <meta content="webkit" name="renderer" />
7
7
  <meta
8
- name="viewport"
9
8
  content="width=device-width,initial-scale=1,user-scalable=no,shrink-to-fit=no,viewport-fit=cover"
9
+ name="viewport"
10
10
  />
11
11
  <title>Page not found</title>
12
- <link type="image/png" href="/.best-shot/logo.png" rel="shortcut icon" />
12
+ <link href="/.best-shot/logo.png" rel="shortcut icon" type="image/png" />
13
13
  <style>
14
14
  html {
15
15
  min-width: 300px;
16
16
  height: 100%;
17
17
  min-height: 300px;
18
- /* stylelint-disable property-no-vendor-prefix */
19
18
  -webkit-user-select: none;
20
19
  -moz-user-select: none;
21
20
  -ms-user-select: none;
@@ -33,9 +32,9 @@
33
32
  align-items: center;
34
33
  justify-content: center;
35
34
  margin: 0;
36
- height: 100%;
37
- color: #999;
38
35
  background-color: white;
36
+ height: 100%;
37
+ color: #999999;
39
38
  font-family: -apple-system, BlinkMacSystemFont, roboto, 'Segoe UI',
40
39
  Segoe, Helvetica, Arial, monospace;
41
40
  }
@@ -77,14 +76,14 @@
77
76
  }
78
77
 
79
78
  a {
80
- color: #93f;
79
+ color: #9933ff;
81
80
  text-decoration: none;
82
81
  cursor: pointer;
83
82
  }
84
83
 
85
84
  @media (prefers-color-scheme: dark) {
86
85
  body {
87
- background-color: #222;
86
+ background-color: #222222;
88
87
  }
89
88
  }
90
89
  </style>
@@ -93,21 +92,21 @@
93
92
  <div style="flex: 3"></div>
94
93
  <div style="text-align: right">
95
94
  <h1>
96
- <img src="/.best-shot/logo.svg" alt="logo" class="logo" />
95
+ <img alt="logo" class="logo" src="/.best-shot/logo.svg" />
97
96
  <span class="text">BEST SHOT</span>
98
97
  </h1>
99
98
  <p>Page not found</p>
100
99
  [? if (publicPath) { ?]
101
100
  <p>
102
101
  Back to
103
- <a rel="noopener noreferrer" href="[?= publicPath ?]">
102
+ <a href="[?= publicPath ?]" rel="noopener noreferrer">
104
103
  [?= publicPath ?]
105
104
  </a>
106
105
  </p>
107
106
  [? } ?]
108
107
  </div>
109
108
  <div style="flex: 2"></div>
110
- <img src="/.best-shot/404.svg" alt="404" class="not-found" />
109
+ <img alt="404" class="not-found" src="/.best-shot/404.svg" />
111
110
 
112
111
  <div style="flex: 8"></div>
113
112
  </body>
@@ -1,9 +1,10 @@
1
- import { compile } from 'ejs';
2
- import { Router } from 'express';
3
1
  import { readFileSync } from 'fs';
4
2
  import { dirname, resolve } from 'path';
5
3
  import { fileURLToPath } from 'url';
6
4
 
5
+ import { compile } from 'ejs';
6
+ import { Router } from 'express';
7
+
7
8
  import { isRaw } from '../../lib/utils.mjs';
8
9
 
9
10
  const router = Router({ strict: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@best-shot/dev-server",
3
- "version": "0.12.6",
3
+ "version": "0.13.0",
4
4
  "description": "DevServer support of `@best-shot/cli`",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -30,29 +30,24 @@
30
30
  "url": "https://github.com/best-shot/best-shot/issues"
31
31
  },
32
32
  "main": "index.mjs",
33
- "exports": {
34
- ".": "./index.mjs",
35
- "./*": "./*"
36
- },
37
33
  "dependencies": {
38
- "@best-shot/config": "^0.1.1",
39
- "@best-shot/preset-serve": "^0.7.5",
34
+ "@best-shot/config": "^0.2.0",
40
35
  "chalk": "^4.1.2",
41
36
  "connect-history-api-fallback": "^1.6.0",
42
37
  "ejs": "^3.1.6",
43
38
  "express": "^4.17.1",
44
39
  "launch-editor-middleware": "^2.2.1",
45
40
  "lodash": "^4.17.21",
46
- "webpack-dev-server": "^4.4.0",
41
+ "webpack-dev-server": "^4.6.0",
47
42
  "webpack-dev-server-waitpage": "^2.1.1"
48
43
  },
49
44
  "peerDependencies": {
50
- "@best-shot/cli": "^0.11.2"
45
+ "@best-shot/cli": "^0.12.0"
51
46
  },
52
47
  "engines": {
53
- "node": "^12.22.0 || ^14.17.0 || >=16.13.0"
48
+ "node": "^14.17.0 || >=16.13.0"
54
49
  },
55
50
  "x-readme": {
56
51
  "logo": "https://cdn.jsdelivr.net/gh/best-shot/best-shot/packages/core/logo.svg"
57
52
  }
58
- }
53
+ }