wxt 0.3.0 → 0.3.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/index.d.ts CHANGED
@@ -240,7 +240,7 @@ interface BaseEntrypoint {
240
240
  outputDir: string;
241
241
  }
242
242
  interface GenericEntrypoint extends BaseEntrypoint {
243
- type: 'sandbox' | 'bookmarks' | 'history' | 'newtab' | 'sidepanel' | 'devtools' | 'unlisted-page' | 'unlisted-script';
243
+ type: 'sandbox' | 'bookmarks' | 'history' | 'newtab' | 'sidepanel' | 'devtools' | 'unlisted-page' | 'unlisted-script' | 'unlisted-style' | 'content-script-style';
244
244
  }
245
245
  interface BackgroundEntrypoint extends BaseEntrypoint {
246
246
  type: 'background';
@@ -404,7 +404,7 @@ interface ExtensionRunnerConfig {
404
404
 
405
405
  type EntrypointGroup = Entrypoint | Entrypoint[];
406
406
 
407
- var version = "0.3.0";
407
+ var version = "0.3.1";
408
408
 
409
409
  declare function defineConfig(config: UserConfig): UserConfig;
410
410
 
package/dist/index.js CHANGED
@@ -15,6 +15,8 @@ function normalizePath2(path5) {
15
15
  function unnormalizePath(path5) {
16
16
  return nodePath.normalize(path5);
17
17
  }
18
+ var CSS_EXTENSIONS = ["css", "scss", "sass", "less", "styl", "stylus"];
19
+ var CSS_EXTENSIONS_PATTERN = `+(${CSS_EXTENSIONS.join("|")})`;
18
20
 
19
21
  // src/core/utils/entrypoints.ts
20
22
  function getEntrypointName(entrypointsDir, inputPath) {
@@ -328,6 +330,30 @@ export default defineBackground(() => void 0)`;
328
330
  }
329
331
  var VIRTUAL_NOOP_BACKGROUND_MODULE_ID = "virtual:user-background";
330
332
 
333
+ // src/core/vite-plugins/cssEntrypoints.ts
334
+ function cssEntrypoints(entrypoint, config) {
335
+ return {
336
+ name: "wxt:css-entrypoint",
337
+ config() {
338
+ return {
339
+ build: {
340
+ rollupOptions: {
341
+ output: {
342
+ assetFileNames: () => getEntrypointBundlePath(entrypoint, config.outDir, ".css")
343
+ }
344
+ }
345
+ }
346
+ };
347
+ },
348
+ generateBundle(_, bundle) {
349
+ Object.keys(bundle).forEach((file) => {
350
+ if (file.endsWith(".js"))
351
+ delete bundle[file];
352
+ });
353
+ }
354
+ };
355
+ }
356
+
331
357
  // src/core/utils/createFsCache.ts
332
358
  import fs3, { ensureDir as ensureDir2 } from "fs-extra";
333
359
  import { dirname as dirname3, resolve as resolve5 } from "path";
@@ -662,7 +688,12 @@ async function buildEntrypoints(groups, config) {
662
688
  async function buildSingleEntrypoint(entrypoint, config) {
663
689
  const isVirtual = ["background", "content-script"].includes(entrypoint.type);
664
690
  const entry = isVirtual ? `virtual:wxt-${entrypoint.type}?${entrypoint.inputPath}` : entrypoint.inputPath;
691
+ const plugins = [];
692
+ if (entrypoint.type === "content-script-style" || entrypoint.type === "unlisted-style") {
693
+ plugins.push(cssEntrypoints(entrypoint, config));
694
+ }
665
695
  const libMode = {
696
+ plugins,
666
697
  build: {
667
698
  lib: {
668
699
  entry,
@@ -758,7 +789,7 @@ async function copyPublicDirectory(config) {
758
789
  // src/core/build/findEntrypoints.ts
759
790
  import { relative as relative3, resolve as resolve9 } from "path";
760
791
  import fs8 from "fs-extra";
761
- import picomatch from "picomatch";
792
+ import { minimatch } from "minimatch";
762
793
  import { parseHTML as parseHTML2 } from "linkedom";
763
794
  import JSON5 from "json5";
764
795
 
@@ -833,7 +864,7 @@ async function findEntrypoints(config) {
833
864
  relativePaths.map(async (relativePath) => {
834
865
  const path5 = resolve9(config.entrypointsDir, relativePath);
835
866
  const matchingGlob = pathGlobs.find(
836
- (glob3) => picomatch.isMatch(relativePath, glob3)
867
+ (glob3) => minimatch(relativePath, glob3)
837
868
  );
838
869
  if (matchingGlob == null) {
839
870
  return config.logger.warn(
@@ -867,6 +898,14 @@ ${JSON.stringify(
867
898
  path5
868
899
  );
869
900
  break;
901
+ case "content-script-style":
902
+ entrypoint = {
903
+ type,
904
+ name: getEntrypointName(config.entrypointsDir, path5),
905
+ inputPath: path5,
906
+ outputDir: resolve9(config.outDir, CONTENT_SCRIPT_OUT_DIR)
907
+ };
908
+ break;
870
909
  default:
871
910
  entrypoint = {
872
911
  type,
@@ -982,7 +1021,7 @@ async function getContentScriptEntrypoint(config, name, path5) {
982
1021
  type: "content-script",
983
1022
  name: getEntrypointName(config.entrypointsDir, path5),
984
1023
  inputPath: path5,
985
- outputDir: resolve9(config.outDir, "content-scripts"),
1024
+ outputDir: resolve9(config.outDir, CONTENT_SCRIPT_OUT_DIR),
986
1025
  options
987
1026
  };
988
1027
  }
@@ -1009,6 +1048,10 @@ var PATH_GLOB_TO_TYPE_MAP = {
1009
1048
  "content/index.ts?(x)": "content-script",
1010
1049
  "*.content.ts?(x)": "content-script",
1011
1050
  "*.content/index.ts?(x)": "content-script",
1051
+ [`content.${CSS_EXTENSIONS_PATTERN}`]: "content-script-style",
1052
+ [`*.content.${CSS_EXTENSIONS_PATTERN}`]: "content-script-style",
1053
+ [`content/index.${CSS_EXTENSIONS_PATTERN}`]: "content-script-style",
1054
+ [`*.content/index.${CSS_EXTENSIONS_PATTERN}`]: "content-script-style",
1012
1055
  "popup.html": "popup",
1013
1056
  "popup/index.html": "popup",
1014
1057
  "options.html": "options",
@@ -1016,9 +1059,13 @@ var PATH_GLOB_TO_TYPE_MAP = {
1016
1059
  "*.html": "unlisted-page",
1017
1060
  "*/index.html": "unlisted-page",
1018
1061
  "*.ts": "unlisted-script",
1062
+ "*/index.ts": "unlisted-script",
1063
+ [`*.${CSS_EXTENSIONS_PATTERN}`]: "unlisted-style",
1064
+ [`*/index.${CSS_EXTENSIONS_PATTERN}`]: "unlisted-style",
1019
1065
  // Don't warn about any files in subdirectories, like CSS or JS entrypoints for HTML files
1020
1066
  "*/*": "ignored"
1021
1067
  };
1068
+ var CONTENT_SCRIPT_OUT_DIR = "content-scripts";
1022
1069
 
1023
1070
  // src/core/build/generateTypesDir.ts
1024
1071
  import { createUnimport as createUnimport3 } from "unimport";
@@ -1273,11 +1320,11 @@ async function generateMainfest(entrypoints, buildOutput, config) {
1273
1320
  addDevModePermissions(manifest, config);
1274
1321
  if (manifest.name == null)
1275
1322
  throw Error(
1276
- "Manifest 'name' is missing. Either:\n1. Set the name in your <root>/package.json\n2. Set a name via the manifest option in your wxt.config.ts"
1323
+ "Manifest 'name' is missing. Either:\n1. Set the name in your <rootDir>/package.json\n2. Set a name via the manifest option in your wxt.config.ts"
1277
1324
  );
1278
1325
  if (manifest.version == null) {
1279
1326
  throw Error(
1280
- "Manifest 'version' is missing. Either:\n1. Add a version in your <root>/package.json\n2. Pass the version via the manifest option in your wxt.config.ts"
1327
+ "Manifest 'version' is missing. Either:\n1. Add a version in your <rootDir>/package.json\n2. Pass the version via the manifest option in your wxt.config.ts"
1281
1328
  );
1282
1329
  }
1283
1330
  return manifest;
@@ -1558,7 +1605,9 @@ var ENTRY_TYPE_TO_GROUP_MAP = {
1558
1605
  "unlisted-page": "extension-page",
1559
1606
  background: "no-group",
1560
1607
  "content-script": "no-group",
1561
- "unlisted-script": "no-group"
1608
+ "unlisted-script": "no-group",
1609
+ "unlisted-style": "no-group",
1610
+ "content-script-style": "no-group"
1562
1611
  };
1563
1612
 
1564
1613
  // src/core/utils/formatDuration.ts
@@ -1878,7 +1927,7 @@ function reloadHtmlPages(groups, server, config) {
1878
1927
  }
1879
1928
 
1880
1929
  // package.json
1881
- var version2 = "0.3.0";
1930
+ var version2 = "0.3.1";
1882
1931
 
1883
1932
  // src/core/utils/defineConfig.ts
1884
1933
  function defineConfig(config) {