@sdeverywhere/plugin-vite 0.1.1 → 0.1.3
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/index.cjs +4 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -20
- package/dist/index.js.map +1 -1
- package/package.json +8 -3
package/dist/index.cjs
CHANGED
|
@@ -1,21 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
5
|
var __export = (target, all) => {
|
|
20
6
|
for (var name in all)
|
|
21
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -69,11 +55,12 @@ var VitePlugin = class {
|
|
|
69
55
|
const server = await (0, import_vite.createServer)(this.options.config);
|
|
70
56
|
await server.listen();
|
|
71
57
|
} else if (((_b = this.options.apply) == null ? void 0 : _b.development) === "watch") {
|
|
72
|
-
const config =
|
|
58
|
+
const config = {
|
|
73
59
|
build: {
|
|
74
60
|
watch: {}
|
|
75
|
-
}
|
|
76
|
-
|
|
61
|
+
},
|
|
62
|
+
...this.options.config
|
|
63
|
+
};
|
|
77
64
|
await (0, import_vite.build)(config);
|
|
78
65
|
}
|
|
79
66
|
}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/plugin.ts"],"sourcesContent":["// Copyright (c) 2022 Climate Interactive / New Venture Fund\n\nexport type { VitePluginOptions } from './options'\nexport { vitePlugin } from './plugin'\n","// Copyright (c) 2022 Climate Interactive / New Venture Fund\n\nimport type { InlineConfig, ViteDevServer } from 'vite'\nimport { build, createServer } from 'vite'\n\nimport type { BuildContext, Plugin } from '@sdeverywhere/build'\n\nimport type { VitePluginOptions } from './options'\n\nexport function vitePlugin(options: VitePluginOptions): Plugin {\n return new VitePlugin(options)\n}\n\nclass VitePlugin implements Plugin {\n constructor(private readonly options: VitePluginOptions) {}\n\n async postGenerate(context: BuildContext): Promise<boolean> {\n // Only build if the plugin is configured to run for 'post-generate'\n return this.buildIfNeeded(context, 'post-generate')\n }\n\n async postBuild(context: BuildContext): Promise<boolean> {\n // Only build if the plugin is configured to run for 'post-build'\n return this.buildIfNeeded(context, 'post-build')\n }\n\n private async buildIfNeeded(context: BuildContext, caller: 'post-generate' | 'post-build'): Promise<boolean> {\n // The apply values default to 'post-build' when left undefined\n const applyDev = this.options.apply?.development || 'post-build'\n const applyProd = this.options.apply?.production || 'post-build'\n\n // Run \"vite build\" only if configured for this mode\n const shouldBuild =\n (context.config.mode === 'development' && applyDev === caller) ||\n (context.config.mode === 'production' && applyProd === caller)\n if (shouldBuild) {\n context.log('info', `Building ${this.options.name}`)\n await build(this.options.config)\n // context.log('info', 'Done!')\n }\n return true\n }\n\n async watch(): Promise<void> {\n if (this.options.apply?.development === 'serve') {\n // Run \"vite dev\", which starts the app in a local server and\n // refreshes when source files are changed\n const server: ViteDevServer = await createServer(this.options.config)\n await server.listen()\n } else if (this.options.apply?.development === 'watch') {\n // Run \"vite build\" in watch mode so that it rebuilds when source\n // files are changed\n const config: InlineConfig = {\n build: {\n // Enable watch mode\n // TODO: Only do this if not already set up in the given config?\n watch: {}\n },\n ...this.options.config\n }\n await build(config)\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/plugin.ts"],"sourcesContent":["// Copyright (c) 2022 Climate Interactive / New Venture Fund\n\nexport type { VitePluginOptions } from './options'\nexport { vitePlugin } from './plugin'\n","// Copyright (c) 2022 Climate Interactive / New Venture Fund\n\nimport type { InlineConfig, ViteDevServer } from 'vite'\nimport { build, createServer } from 'vite'\n\nimport type { BuildContext, Plugin } from '@sdeverywhere/build'\n\nimport type { VitePluginOptions } from './options'\n\nexport function vitePlugin(options: VitePluginOptions): Plugin {\n return new VitePlugin(options)\n}\n\nclass VitePlugin implements Plugin {\n constructor(private readonly options: VitePluginOptions) {}\n\n async postGenerate(context: BuildContext): Promise<boolean> {\n // Only build if the plugin is configured to run for 'post-generate'\n return this.buildIfNeeded(context, 'post-generate')\n }\n\n async postBuild(context: BuildContext): Promise<boolean> {\n // Only build if the plugin is configured to run for 'post-build'\n return this.buildIfNeeded(context, 'post-build')\n }\n\n private async buildIfNeeded(context: BuildContext, caller: 'post-generate' | 'post-build'): Promise<boolean> {\n // The apply values default to 'post-build' when left undefined\n const applyDev = this.options.apply?.development || 'post-build'\n const applyProd = this.options.apply?.production || 'post-build'\n\n // Run \"vite build\" only if configured for this mode\n const shouldBuild =\n (context.config.mode === 'development' && applyDev === caller) ||\n (context.config.mode === 'production' && applyProd === caller)\n if (shouldBuild) {\n context.log('info', `Building ${this.options.name}`)\n await build(this.options.config)\n // context.log('info', 'Done!')\n }\n return true\n }\n\n async watch(): Promise<void> {\n if (this.options.apply?.development === 'serve') {\n // Run \"vite dev\", which starts the app in a local server and\n // refreshes when source files are changed\n const server: ViteDevServer = await createServer(this.options.config)\n await server.listen()\n } else if (this.options.apply?.development === 'watch') {\n // Run \"vite build\" in watch mode so that it rebuilds when source\n // files are changed\n const config: InlineConfig = {\n build: {\n // Enable watch mode\n // TODO: Only do this if not already set up in the given config?\n watch: {}\n },\n ...this.options.config\n }\n await build(config)\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGA,kBAAoC;AAM7B,SAAS,WAAW,SAAoC;AAC7D,SAAO,IAAI,WAAW,OAAO;AAC/B;AAEA,IAAM,aAAN,MAAmC;AAAA,EACjC,YAA6B,SAA4B;AAA5B;AAAA,EAA6B;AAAA,EAE1D,MAAM,aAAa,SAAyC;AAE1D,WAAO,KAAK,cAAc,SAAS,eAAe;AAAA,EACpD;AAAA,EAEA,MAAM,UAAU,SAAyC;AAEvD,WAAO,KAAK,cAAc,SAAS,YAAY;AAAA,EACjD;AAAA,EAEA,MAAc,cAAc,SAAuB,QAA0D;AA1B/G;AA4BI,UAAM,aAAW,UAAK,QAAQ,UAAb,mBAAoB,gBAAe;AACpD,UAAM,cAAY,UAAK,QAAQ,UAAb,mBAAoB,eAAc;AAGpD,UAAM,cACH,QAAQ,OAAO,SAAS,iBAAiB,aAAa,UACtD,QAAQ,OAAO,SAAS,gBAAgB,cAAc;AACzD,QAAI,aAAa;AACf,cAAQ,IAAI,QAAQ,YAAY,KAAK,QAAQ,MAAM;AACnD,gBAAM,mBAAM,KAAK,QAAQ,MAAM;AAAA,IAEjC;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,QAAuB;AA3C/B;AA4CI,UAAI,UAAK,QAAQ,UAAb,mBAAoB,iBAAgB,SAAS;AAG/C,YAAM,SAAwB,UAAM,0BAAa,KAAK,QAAQ,MAAM;AACpE,YAAM,OAAO,OAAO;AAAA,IACtB,aAAW,UAAK,QAAQ,UAAb,mBAAoB,iBAAgB,SAAS;AAGtD,YAAM,SAAuB;AAAA,QAC3B,OAAO;AAAA,UAGL,OAAO,CAAC;AAAA,QACV;AAAA,QACA,GAAG,KAAK,QAAQ;AAAA,MAClB;AACA,gBAAM,mBAAM,MAAM;AAAA,IACpB;AAAA,EACF;AACF;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __spreadValues = (a, b) => {
|
|
7
|
-
for (var prop in b || (b = {}))
|
|
8
|
-
if (__hasOwnProp.call(b, prop))
|
|
9
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10
|
-
if (__getOwnPropSymbols)
|
|
11
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
-
if (__propIsEnum.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
}
|
|
15
|
-
return a;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
1
|
// src/plugin.ts
|
|
19
2
|
import { build, createServer } from "vite";
|
|
20
3
|
function vitePlugin(options) {
|
|
@@ -47,11 +30,12 @@ var VitePlugin = class {
|
|
|
47
30
|
const server = await createServer(this.options.config);
|
|
48
31
|
await server.listen();
|
|
49
32
|
} else if (((_b = this.options.apply) == null ? void 0 : _b.development) === "watch") {
|
|
50
|
-
const config =
|
|
33
|
+
const config = {
|
|
51
34
|
build: {
|
|
52
35
|
watch: {}
|
|
53
|
-
}
|
|
54
|
-
|
|
36
|
+
},
|
|
37
|
+
...this.options.config
|
|
38
|
+
};
|
|
55
39
|
await build(config);
|
|
56
40
|
}
|
|
57
41
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["// Copyright (c) 2022 Climate Interactive / New Venture Fund\n\nimport type { InlineConfig, ViteDevServer } from 'vite'\nimport { build, createServer } from 'vite'\n\nimport type { BuildContext, Plugin } from '@sdeverywhere/build'\n\nimport type { VitePluginOptions } from './options'\n\nexport function vitePlugin(options: VitePluginOptions): Plugin {\n return new VitePlugin(options)\n}\n\nclass VitePlugin implements Plugin {\n constructor(private readonly options: VitePluginOptions) {}\n\n async postGenerate(context: BuildContext): Promise<boolean> {\n // Only build if the plugin is configured to run for 'post-generate'\n return this.buildIfNeeded(context, 'post-generate')\n }\n\n async postBuild(context: BuildContext): Promise<boolean> {\n // Only build if the plugin is configured to run for 'post-build'\n return this.buildIfNeeded(context, 'post-build')\n }\n\n private async buildIfNeeded(context: BuildContext, caller: 'post-generate' | 'post-build'): Promise<boolean> {\n // The apply values default to 'post-build' when left undefined\n const applyDev = this.options.apply?.development || 'post-build'\n const applyProd = this.options.apply?.production || 'post-build'\n\n // Run \"vite build\" only if configured for this mode\n const shouldBuild =\n (context.config.mode === 'development' && applyDev === caller) ||\n (context.config.mode === 'production' && applyProd === caller)\n if (shouldBuild) {\n context.log('info', `Building ${this.options.name}`)\n await build(this.options.config)\n // context.log('info', 'Done!')\n }\n return true\n }\n\n async watch(): Promise<void> {\n if (this.options.apply?.development === 'serve') {\n // Run \"vite dev\", which starts the app in a local server and\n // refreshes when source files are changed\n const server: ViteDevServer = await createServer(this.options.config)\n await server.listen()\n } else if (this.options.apply?.development === 'watch') {\n // Run \"vite build\" in watch mode so that it rebuilds when source\n // files are changed\n const config: InlineConfig = {\n build: {\n // Enable watch mode\n // TODO: Only do this if not already set up in the given config?\n watch: {}\n },\n ...this.options.config\n }\n await build(config)\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["// Copyright (c) 2022 Climate Interactive / New Venture Fund\n\nimport type { InlineConfig, ViteDevServer } from 'vite'\nimport { build, createServer } from 'vite'\n\nimport type { BuildContext, Plugin } from '@sdeverywhere/build'\n\nimport type { VitePluginOptions } from './options'\n\nexport function vitePlugin(options: VitePluginOptions): Plugin {\n return new VitePlugin(options)\n}\n\nclass VitePlugin implements Plugin {\n constructor(private readonly options: VitePluginOptions) {}\n\n async postGenerate(context: BuildContext): Promise<boolean> {\n // Only build if the plugin is configured to run for 'post-generate'\n return this.buildIfNeeded(context, 'post-generate')\n }\n\n async postBuild(context: BuildContext): Promise<boolean> {\n // Only build if the plugin is configured to run for 'post-build'\n return this.buildIfNeeded(context, 'post-build')\n }\n\n private async buildIfNeeded(context: BuildContext, caller: 'post-generate' | 'post-build'): Promise<boolean> {\n // The apply values default to 'post-build' when left undefined\n const applyDev = this.options.apply?.development || 'post-build'\n const applyProd = this.options.apply?.production || 'post-build'\n\n // Run \"vite build\" only if configured for this mode\n const shouldBuild =\n (context.config.mode === 'development' && applyDev === caller) ||\n (context.config.mode === 'production' && applyProd === caller)\n if (shouldBuild) {\n context.log('info', `Building ${this.options.name}`)\n await build(this.options.config)\n // context.log('info', 'Done!')\n }\n return true\n }\n\n async watch(): Promise<void> {\n if (this.options.apply?.development === 'serve') {\n // Run \"vite dev\", which starts the app in a local server and\n // refreshes when source files are changed\n const server: ViteDevServer = await createServer(this.options.config)\n await server.listen()\n } else if (this.options.apply?.development === 'watch') {\n // Run \"vite build\" in watch mode so that it rebuilds when source\n // files are changed\n const config: InlineConfig = {\n build: {\n // Enable watch mode\n // TODO: Only do this if not already set up in the given config?\n watch: {}\n },\n ...this.options.config\n }\n await build(config)\n }\n }\n}\n"],"mappings":";AAGA,SAAS,OAAO,oBAAoB;AAM7B,SAAS,WAAW,SAAoC;AAC7D,SAAO,IAAI,WAAW,OAAO;AAC/B;AAEA,IAAM,aAAN,MAAmC;AAAA,EACjC,YAA6B,SAA4B;AAA5B;AAAA,EAA6B;AAAA,EAE1D,MAAM,aAAa,SAAyC;AAE1D,WAAO,KAAK,cAAc,SAAS,eAAe;AAAA,EACpD;AAAA,EAEA,MAAM,UAAU,SAAyC;AAEvD,WAAO,KAAK,cAAc,SAAS,YAAY;AAAA,EACjD;AAAA,EAEA,MAAc,cAAc,SAAuB,QAA0D;AA1B/G;AA4BI,UAAM,aAAW,UAAK,QAAQ,UAAb,mBAAoB,gBAAe;AACpD,UAAM,cAAY,UAAK,QAAQ,UAAb,mBAAoB,eAAc;AAGpD,UAAM,cACH,QAAQ,OAAO,SAAS,iBAAiB,aAAa,UACtD,QAAQ,OAAO,SAAS,gBAAgB,cAAc;AACzD,QAAI,aAAa;AACf,cAAQ,IAAI,QAAQ,YAAY,KAAK,QAAQ,MAAM;AACnD,YAAM,MAAM,KAAK,QAAQ,MAAM;AAAA,IAEjC;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,QAAuB;AA3C/B;AA4CI,UAAI,UAAK,QAAQ,UAAb,mBAAoB,iBAAgB,SAAS;AAG/C,YAAM,SAAwB,MAAM,aAAa,KAAK,QAAQ,MAAM;AACpE,YAAM,OAAO,OAAO;AAAA,IACtB,aAAW,UAAK,QAAQ,UAAb,mBAAoB,iBAAgB,SAAS;AAGtD,YAAM,SAAuB;AAAA,QAC3B,OAAO;AAAA,UAGL,OAAO,CAAC;AAAA,QACV;AAAA,QACA,GAAG,KAAK,QAAQ;AAAA,MAClB;AACA,YAAM,MAAM,MAAM;AAAA,IACpB;AAAA,EACF;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdeverywhere/plugin-vite",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist/**"
|
|
6
6
|
],
|
|
@@ -16,8 +16,13 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"
|
|
20
|
-
|
|
19
|
+
"vite": "^3.1.3"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"@sdeverywhere/build": "^0.2.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@sdeverywhere/build": "*"
|
|
21
26
|
},
|
|
22
27
|
"author": "Climate Interactive",
|
|
23
28
|
"license": "MIT",
|