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.cjs CHANGED
@@ -55,6 +55,8 @@ function normalizePath2(path5) {
55
55
  function unnormalizePath(path5) {
56
56
  return import_node_path.default.normalize(path5);
57
57
  }
58
+ var CSS_EXTENSIONS = ["css", "scss", "sass", "less", "styl", "stylus"];
59
+ var CSS_EXTENSIONS_PATTERN = `+(${CSS_EXTENSIONS.join("|")})`;
58
60
 
59
61
  // src/core/utils/entrypoints.ts
60
62
  function getEntrypointName(entrypointsDir, inputPath) {
@@ -368,6 +370,30 @@ export default defineBackground(() => void 0)`;
368
370
  }
369
371
  var VIRTUAL_NOOP_BACKGROUND_MODULE_ID = "virtual:user-background";
370
372
 
373
+ // src/core/vite-plugins/cssEntrypoints.ts
374
+ function cssEntrypoints(entrypoint, config) {
375
+ return {
376
+ name: "wxt:css-entrypoint",
377
+ config() {
378
+ return {
379
+ build: {
380
+ rollupOptions: {
381
+ output: {
382
+ assetFileNames: () => getEntrypointBundlePath(entrypoint, config.outDir, ".css")
383
+ }
384
+ }
385
+ }
386
+ };
387
+ },
388
+ generateBundle(_, bundle) {
389
+ Object.keys(bundle).forEach((file) => {
390
+ if (file.endsWith(".js"))
391
+ delete bundle[file];
392
+ });
393
+ }
394
+ };
395
+ }
396
+
371
397
  // src/core/utils/createFsCache.ts
372
398
  var import_fs_extra3 = __toESM(require("fs-extra"), 1);
373
399
  var import_path4 = require("path");
@@ -702,7 +728,12 @@ async function buildEntrypoints(groups, config) {
702
728
  async function buildSingleEntrypoint(entrypoint, config) {
703
729
  const isVirtual = ["background", "content-script"].includes(entrypoint.type);
704
730
  const entry = isVirtual ? `virtual:wxt-${entrypoint.type}?${entrypoint.inputPath}` : entrypoint.inputPath;
731
+ const plugins = [];
732
+ if (entrypoint.type === "content-script-style" || entrypoint.type === "unlisted-style") {
733
+ plugins.push(cssEntrypoints(entrypoint, config));
734
+ }
705
735
  const libMode = {
736
+ plugins,
706
737
  build: {
707
738
  lib: {
708
739
  entry,
@@ -798,7 +829,7 @@ async function copyPublicDirectory(config) {
798
829
  // src/core/build/findEntrypoints.ts
799
830
  var import_path8 = require("path");
800
831
  var import_fs_extra8 = __toESM(require("fs-extra"), 1);
801
- var import_picomatch = __toESM(require("picomatch"), 1);
832
+ var import_minimatch = require("minimatch");
802
833
  var import_linkedom2 = require("linkedom");
803
834
  var import_json5 = __toESM(require("json5"), 1);
804
835
 
@@ -873,7 +904,7 @@ async function findEntrypoints(config) {
873
904
  relativePaths.map(async (relativePath) => {
874
905
  const path5 = (0, import_path8.resolve)(config.entrypointsDir, relativePath);
875
906
  const matchingGlob = pathGlobs.find(
876
- (glob3) => import_picomatch.default.isMatch(relativePath, glob3)
907
+ (glob3) => (0, import_minimatch.minimatch)(relativePath, glob3)
877
908
  );
878
909
  if (matchingGlob == null) {
879
910
  return config.logger.warn(
@@ -907,6 +938,14 @@ ${JSON.stringify(
907
938
  path5
908
939
  );
909
940
  break;
941
+ case "content-script-style":
942
+ entrypoint = {
943
+ type,
944
+ name: getEntrypointName(config.entrypointsDir, path5),
945
+ inputPath: path5,
946
+ outputDir: (0, import_path8.resolve)(config.outDir, CONTENT_SCRIPT_OUT_DIR)
947
+ };
948
+ break;
910
949
  default:
911
950
  entrypoint = {
912
951
  type,
@@ -1022,7 +1061,7 @@ async function getContentScriptEntrypoint(config, name, path5) {
1022
1061
  type: "content-script",
1023
1062
  name: getEntrypointName(config.entrypointsDir, path5),
1024
1063
  inputPath: path5,
1025
- outputDir: (0, import_path8.resolve)(config.outDir, "content-scripts"),
1064
+ outputDir: (0, import_path8.resolve)(config.outDir, CONTENT_SCRIPT_OUT_DIR),
1026
1065
  options
1027
1066
  };
1028
1067
  }
@@ -1049,6 +1088,10 @@ var PATH_GLOB_TO_TYPE_MAP = {
1049
1088
  "content/index.ts?(x)": "content-script",
1050
1089
  "*.content.ts?(x)": "content-script",
1051
1090
  "*.content/index.ts?(x)": "content-script",
1091
+ [`content.${CSS_EXTENSIONS_PATTERN}`]: "content-script-style",
1092
+ [`*.content.${CSS_EXTENSIONS_PATTERN}`]: "content-script-style",
1093
+ [`content/index.${CSS_EXTENSIONS_PATTERN}`]: "content-script-style",
1094
+ [`*.content/index.${CSS_EXTENSIONS_PATTERN}`]: "content-script-style",
1052
1095
  "popup.html": "popup",
1053
1096
  "popup/index.html": "popup",
1054
1097
  "options.html": "options",
@@ -1056,9 +1099,13 @@ var PATH_GLOB_TO_TYPE_MAP = {
1056
1099
  "*.html": "unlisted-page",
1057
1100
  "*/index.html": "unlisted-page",
1058
1101
  "*.ts": "unlisted-script",
1102
+ "*/index.ts": "unlisted-script",
1103
+ [`*.${CSS_EXTENSIONS_PATTERN}`]: "unlisted-style",
1104
+ [`*/index.${CSS_EXTENSIONS_PATTERN}`]: "unlisted-style",
1059
1105
  // Don't warn about any files in subdirectories, like CSS or JS entrypoints for HTML files
1060
1106
  "*/*": "ignored"
1061
1107
  };
1108
+ var CONTENT_SCRIPT_OUT_DIR = "content-scripts";
1062
1109
 
1063
1110
  // src/core/build/generateTypesDir.ts
1064
1111
  var import_unimport3 = require("unimport");
@@ -1313,11 +1360,11 @@ async function generateMainfest(entrypoints, buildOutput, config) {
1313
1360
  addDevModePermissions(manifest, config);
1314
1361
  if (manifest.name == null)
1315
1362
  throw Error(
1316
- "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"
1363
+ "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"
1317
1364
  );
1318
1365
  if (manifest.version == null) {
1319
1366
  throw Error(
1320
- "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"
1367
+ "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"
1321
1368
  );
1322
1369
  }
1323
1370
  return manifest;
@@ -1598,7 +1645,9 @@ var ENTRY_TYPE_TO_GROUP_MAP = {
1598
1645
  "unlisted-page": "extension-page",
1599
1646
  background: "no-group",
1600
1647
  "content-script": "no-group",
1601
- "unlisted-script": "no-group"
1648
+ "unlisted-script": "no-group",
1649
+ "unlisted-style": "no-group",
1650
+ "content-script-style": "no-group"
1602
1651
  };
1603
1652
 
1604
1653
  // src/core/utils/formatDuration.ts
@@ -1918,7 +1967,7 @@ function reloadHtmlPages(groups, server, config) {
1918
1967
  }
1919
1968
 
1920
1969
  // package.json
1921
- var version2 = "0.3.0";
1970
+ var version2 = "0.3.1";
1922
1971
 
1923
1972
  // src/core/utils/defineConfig.ts
1924
1973
  function defineConfig(config) {