@webiny/website-builder-nextjs 0.0.0-unstable.e53eceafb5 → 0.0.0-unstable.eb196ccd2f

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/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@webiny/website-builder-nextjs",
3
- "version": "0.0.0-unstable.e53eceafb5",
3
+ "version": "0.0.0-unstable.eb196ccd2f",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/webiny/webiny-js.git"
8
8
  },
9
9
  "exports": {
10
- ".": "./index.js"
10
+ ".": "./index.js",
11
+ "./webpack": "./webpack.js"
11
12
  },
12
13
  "description": "A Next.js integration SDK for Webiny Website Builder.",
13
14
  "contributors": [
@@ -17,14 +18,16 @@
17
18
  ],
18
19
  "license": "MIT",
19
20
  "dependencies": {
20
- "@webiny/website-builder-react": "0.0.0-unstable.e53eceafb5"
21
- },
22
- "peerDependencies": {
23
- "next": "^15"
21
+ "@webiny/website-builder-react": "0.0.0-unstable.eb196ccd2f",
22
+ "postcss": "8.5.6",
23
+ "postcss-import": "16.1.1"
24
24
  },
25
25
  "devDependencies": {
26
- "@webiny/project-utils": "0.0.0-unstable.e53eceafb5",
27
- "typescript": "5.3.3"
26
+ "@types/postcss-import": "14.0.3",
27
+ "@webiny/project-utils": "0.0.0-unstable.eb196ccd2f",
28
+ "next": "15.4.6",
29
+ "typescript": "5.3.3",
30
+ "webpack": "5.101.1"
28
31
  },
29
32
  "publishConfig": {
30
33
  "access": "public",
@@ -37,10 +40,11 @@
37
40
  "adio": {
38
41
  "ignore": {
39
42
  "dependencies": [
40
- "next",
43
+ "postcss",
44
+ "postcss-import",
41
45
  "@webiny/website-builder-react"
42
46
  ]
43
47
  }
44
48
  },
45
- "gitHead": "e53eceafb5ce1a3872c9b4548939bb2eae5b1aef"
49
+ "gitHead": "eb196ccd2f32296e10f7add6dd7220d4e3abece4"
46
50
  }
package/webpack.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import type { WebpackPluginInstance } from "webpack";
2
+ import type { NextConfig } from "next";
3
+ type WebpackConfigContext = Parameters<NonNullable<NextConfig["webpack"]>>[1];
4
+ export declare const injectThemeCss: (entry: string, variableName?: string) => Promise<{
5
+ getPlugins: (context: WebpackConfigContext) => WebpackPluginInstance[];
6
+ }>;
7
+ export {};
package/webpack.js ADDED
@@ -0,0 +1,56 @@
1
+ import fs from "fs";
2
+ import postcss from "postcss";
3
+ import postcssImport from "postcss-import";
4
+
5
+ // We're inferring the type from Next's config type.
6
+
7
+ const buildThemeCss = async entry => {
8
+ // Read CSS entry file.
9
+ const raw = fs.readFileSync(entry, "utf8");
10
+
11
+ // Inline local imports.
12
+ const result = await postcss([postcssImport()]).process(raw, {
13
+ from: entry
14
+ });
15
+ return result.css;
16
+ };
17
+ export const injectThemeCss = async (entry, variableName) => {
18
+ const defineKey = variableName ?? "__THEME_CSS__";
19
+ const initialCss = await buildThemeCss(entry);
20
+
21
+ // Inject as a global constant available in your app.
22
+ let definePlugin;
23
+ const getPlugins = context => {
24
+ const {
25
+ dev,
26
+ webpack
27
+ } = context;
28
+ if (!definePlugin) {
29
+ definePlugin = new webpack.DefinePlugin({
30
+ [defineKey]: JSON.stringify(initialCss)
31
+ });
32
+ }
33
+ const plugins = [definePlugin];
34
+ if (dev) {
35
+ // Watch for changes and update plugin definitions
36
+ plugins.push({
37
+ apply(compiler) {
38
+ compiler.hooks.afterCompile.tapPromise("WatchThemeCss", async compilation => {
39
+ compilation.fileDependencies.add(entry);
40
+ });
41
+ compiler.hooks.beforeCompile.tapPromise("UpdateThemeCss", async () => {
42
+ const cssValue = await buildThemeCss(entry);
43
+ // Update the definitions on our specific plugin
44
+ definePlugin.definitions[defineKey] = JSON.stringify(cssValue);
45
+ });
46
+ }
47
+ });
48
+ }
49
+ return plugins;
50
+ };
51
+ return {
52
+ getPlugins
53
+ };
54
+ };
55
+
56
+ //# sourceMappingURL=webpack.js.map
package/webpack.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["fs","postcss","postcssImport","buildThemeCss","entry","raw","readFileSync","result","process","from","css","injectThemeCss","variableName","defineKey","initialCss","definePlugin","getPlugins","context","dev","webpack","DefinePlugin","JSON","stringify","plugins","push","apply","compiler","hooks","afterCompile","tapPromise","compilation","fileDependencies","add","beforeCompile","cssValue","definitions"],"sources":["webpack.ts"],"sourcesContent":["import fs from \"fs\";\nimport type { WebpackPluginInstance } from \"webpack\";\nimport postcss from \"postcss\";\nimport postcssImport from \"postcss-import\";\nimport type { NextConfig } from \"next\";\n\n// We're inferring the type from Next's config type.\ntype WebpackConfigContext = Parameters<NonNullable<NextConfig[\"webpack\"]>>[1];\n\nconst buildThemeCss = async (entry: string) => {\n // Read CSS entry file.\n const raw = fs.readFileSync(entry, \"utf8\");\n\n // Inline local imports.\n const result = await postcss([postcssImport()]).process(raw, { from: entry });\n\n return result.css;\n};\n\nexport const injectThemeCss = async (entry: string, variableName?: string) => {\n const defineKey = variableName ?? \"__THEME_CSS__\";\n\n const initialCss = await buildThemeCss(entry);\n\n // Inject as a global constant available in your app.\n let definePlugin: WebpackPluginInstance;\n\n const getPlugins = (context: WebpackConfigContext) => {\n const { dev, webpack } = context;\n\n if (!definePlugin) {\n definePlugin = new webpack.DefinePlugin({ [defineKey]: JSON.stringify(initialCss) });\n }\n\n const plugins: WebpackPluginInstance[] = [definePlugin];\n\n if (dev) {\n // Watch for changes and update plugin definitions\n plugins.push({\n apply(compiler) {\n compiler.hooks.afterCompile.tapPromise(\"WatchThemeCss\", async compilation => {\n compilation.fileDependencies.add(entry);\n });\n\n compiler.hooks.beforeCompile.tapPromise(\"UpdateThemeCss\", async () => {\n const cssValue = await buildThemeCss(entry);\n // Update the definitions on our specific plugin\n definePlugin.definitions[defineKey] = JSON.stringify(cssValue);\n });\n }\n });\n }\n\n return plugins;\n };\n\n return { getPlugins };\n};\n"],"mappings":"AAAA,OAAOA,EAAE,MA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