@vanilla-extract/next-plugin 2.1.1 → 2.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.
@@ -0,0 +1,7 @@
1
+ import { VanillaExtractPlugin } from '@vanilla-extract/webpack-plugin';
2
+ import { NextConfig } from 'next/types';
3
+
4
+ type PluginOptions = ConstructorParameters<typeof VanillaExtractPlugin>[0];
5
+ declare const createVanillaExtractPlugin: (pluginOptions?: PluginOptions) => (nextConfig?: NextConfig) => NextConfig;
6
+
7
+ export { createVanillaExtractPlugin };
@@ -13,23 +13,22 @@ var browserslist__default = /*#__PURE__*/_interopDefault(browserslist);
13
13
 
14
14
  function getSupportedBrowsers(dir, isDevelopment) {
15
15
  let browsers;
16
-
17
16
  try {
18
17
  browsers = browserslist__default["default"].loadConfig({
19
18
  path: dir,
20
19
  env: isDevelopment ? 'development' : 'production'
21
20
  });
22
21
  } catch {}
23
-
24
22
  return browsers;
25
23
  }
26
-
27
24
  const createVanillaExtractPlugin = (pluginOptions = {}) => (nextConfig = {}) => Object.assign({}, nextConfig, {
28
25
  webpack(config, options) {
26
+ var _resolvedNextConfig$e;
29
27
  const {
30
28
  dir,
31
29
  dev,
32
- isServer
30
+ isServer,
31
+ config: resolvedNextConfig
33
32
  } = options;
34
33
  const cssRules = config.module.rules.find(rule => Array.isArray(rule.oneOf) && rule.oneOf.some(({
35
34
  test
@@ -42,22 +41,21 @@ const createVanillaExtractPlugin = (pluginOptions = {}) => (nextConfig = {}) =>
42
41
  isClient: !isServer,
43
42
  isServer,
44
43
  isDevelopment: dev,
45
- future: nextConfig.future || {},
46
- experimental: nextConfig.experimental || {}
47
- }, () => css.lazyPostCSS(dir, getSupportedBrowsers(dir, dev)), [])
44
+ future: resolvedNextConfig.future || {},
45
+ experimental: resolvedNextConfig.experimental || {},
46
+ // @ts-ignore -- 'appDir' config is in beta
47
+ hasAppDir: (_resolvedNextConfig$e = resolvedNextConfig.experimental) === null || _resolvedNextConfig$e === void 0 ? void 0 : _resolvedNextConfig$e.appDir
48
+ }, () => css.lazyPostCSS(dir, getSupportedBrowsers(dir, dev), undefined), [])
48
49
  });
49
50
  config.plugins.push(new webpackPlugin.VanillaExtractPlugin({
50
51
  outputCss: !isServer,
51
52
  ...pluginOptions
52
53
  }));
53
-
54
54
  if (typeof nextConfig.webpack === 'function') {
55
55
  return nextConfig.webpack(config, options);
56
56
  }
57
-
58
57
  return config;
59
58
  }
60
-
61
59
  });
62
60
 
63
61
  exports.createVanillaExtractPlugin = createVanillaExtractPlugin;
@@ -13,23 +13,22 @@ var browserslist__default = /*#__PURE__*/_interopDefault(browserslist);
13
13
 
14
14
  function getSupportedBrowsers(dir, isDevelopment) {
15
15
  let browsers;
16
-
17
16
  try {
18
17
  browsers = browserslist__default["default"].loadConfig({
19
18
  path: dir,
20
19
  env: isDevelopment ? 'development' : 'production'
21
20
  });
22
21
  } catch {}
23
-
24
22
  return browsers;
25
23
  }
26
-
27
24
  const createVanillaExtractPlugin = (pluginOptions = {}) => (nextConfig = {}) => Object.assign({}, nextConfig, {
28
25
  webpack(config, options) {
26
+ var _resolvedNextConfig$e;
29
27
  const {
30
28
  dir,
31
29
  dev,
32
- isServer
30
+ isServer,
31
+ config: resolvedNextConfig
33
32
  } = options;
34
33
  const cssRules = config.module.rules.find(rule => Array.isArray(rule.oneOf) && rule.oneOf.some(({
35
34
  test
@@ -42,22 +41,21 @@ const createVanillaExtractPlugin = (pluginOptions = {}) => (nextConfig = {}) =>
42
41
  isClient: !isServer,
43
42
  isServer,
44
43
  isDevelopment: dev,
45
- future: nextConfig.future || {},
46
- experimental: nextConfig.experimental || {}
47
- }, () => css.lazyPostCSS(dir, getSupportedBrowsers(dir, dev)), [])
44
+ future: resolvedNextConfig.future || {},
45
+ experimental: resolvedNextConfig.experimental || {},
46
+ // @ts-ignore -- 'appDir' config is in beta
47
+ hasAppDir: (_resolvedNextConfig$e = resolvedNextConfig.experimental) === null || _resolvedNextConfig$e === void 0 ? void 0 : _resolvedNextConfig$e.appDir
48
+ }, () => css.lazyPostCSS(dir, getSupportedBrowsers(dir, dev), undefined), [])
48
49
  });
49
50
  config.plugins.push(new webpackPlugin.VanillaExtractPlugin({
50
51
  outputCss: !isServer,
51
52
  ...pluginOptions
52
53
  }));
53
-
54
54
  if (typeof nextConfig.webpack === 'function') {
55
55
  return nextConfig.webpack(config, options);
56
56
  }
57
-
58
57
  return config;
59
58
  }
60
-
61
59
  });
62
60
 
63
61
  exports.createVanillaExtractPlugin = createVanillaExtractPlugin;
@@ -5,23 +5,22 @@ import { getGlobalCssLoader } from 'next/dist/build/webpack/config/blocks/css/lo
5
5
 
6
6
  function getSupportedBrowsers(dir, isDevelopment) {
7
7
  let browsers;
8
-
9
8
  try {
10
9
  browsers = browserslist.loadConfig({
11
10
  path: dir,
12
11
  env: isDevelopment ? 'development' : 'production'
13
12
  });
14
13
  } catch {}
15
-
16
14
  return browsers;
17
15
  }
18
-
19
16
  const createVanillaExtractPlugin = (pluginOptions = {}) => (nextConfig = {}) => Object.assign({}, nextConfig, {
20
17
  webpack(config, options) {
18
+ var _resolvedNextConfig$e;
21
19
  const {
22
20
  dir,
23
21
  dev,
24
- isServer
22
+ isServer,
23
+ config: resolvedNextConfig
25
24
  } = options;
26
25
  const cssRules = config.module.rules.find(rule => Array.isArray(rule.oneOf) && rule.oneOf.some(({
27
26
  test
@@ -34,22 +33,21 @@ const createVanillaExtractPlugin = (pluginOptions = {}) => (nextConfig = {}) =>
34
33
  isClient: !isServer,
35
34
  isServer,
36
35
  isDevelopment: dev,
37
- future: nextConfig.future || {},
38
- experimental: nextConfig.experimental || {}
39
- }, () => lazyPostCSS(dir, getSupportedBrowsers(dir, dev)), [])
36
+ future: resolvedNextConfig.future || {},
37
+ experimental: resolvedNextConfig.experimental || {},
38
+ // @ts-ignore -- 'appDir' config is in beta
39
+ hasAppDir: (_resolvedNextConfig$e = resolvedNextConfig.experimental) === null || _resolvedNextConfig$e === void 0 ? void 0 : _resolvedNextConfig$e.appDir
40
+ }, () => lazyPostCSS(dir, getSupportedBrowsers(dir, dev), undefined), [])
40
41
  });
41
42
  config.plugins.push(new VanillaExtractPlugin({
42
43
  outputCss: !isServer,
43
44
  ...pluginOptions
44
45
  }));
45
-
46
46
  if (typeof nextConfig.webpack === 'function') {
47
47
  return nextConfig.webpack(config, options);
48
48
  }
49
-
50
49
  return config;
51
50
  }
52
-
53
51
  });
54
52
 
55
53
  export { createVanillaExtractPlugin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vanilla-extract/next-plugin",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "Zero-runtime Stylesheets-in-TypeScript",
5
5
  "main": "dist/vanilla-extract-next-plugin.cjs.js",
6
6
  "module": "dist/vanilla-extract-next-plugin.esm.js",