@vanilla-extract/next-plugin 0.0.0-alternative-webpack-loader-20228910529

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,60 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var webpackPlugin = require('@vanilla-extract/webpack-plugin');
6
+ var browserslist = require('browserslist');
7
+ var css = require('next/dist/build/webpack/config/blocks/css');
8
+ var loaders = require('next/dist/build/webpack/config/blocks/css/loaders');
9
+
10
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
11
+
12
+ var browserslist__default = /*#__PURE__*/_interopDefault(browserslist);
13
+
14
+ function getSupportedBrowsers(dir, isDevelopment) {
15
+ let browsers;
16
+
17
+ try {
18
+ browsers = browserslist__default["default"].loadConfig({
19
+ path: dir,
20
+ env: isDevelopment ? 'development' : 'production'
21
+ });
22
+ } catch {}
23
+
24
+ return browsers;
25
+ }
26
+
27
+ const createVanillaExtractPlugin = (pluginOptions = {}) => (nextConfig = {}) => Object.assign({}, nextConfig, {
28
+ webpack(config, options) {
29
+ const {
30
+ dir,
31
+ dev,
32
+ isServer
33
+ } = options;
34
+ const cssRules = config.module.rules.find(rule => Array.isArray(rule.oneOf) && rule.oneOf.some(({
35
+ test
36
+ }) => typeof test === 'object' && typeof test.test === 'function' && test.test('filename.css'))).oneOf;
37
+ cssRules.unshift({
38
+ test: /\.vanilla\.css$/i,
39
+ sideEffects: true,
40
+ use: loaders.getGlobalCssLoader({
41
+ assetPrefix: config.assetPrefix,
42
+ isClient: !isServer,
43
+ isServer,
44
+ isDevelopment: dev,
45
+ future: nextConfig.future || {},
46
+ experimental: nextConfig.experimental || {}
47
+ }, () => css.lazyPostCSS(dir, getSupportedBrowsers(dir, dev)), [])
48
+ });
49
+ config.plugins.push(new webpackPlugin.VanillaExtractPlugin(pluginOptions));
50
+
51
+ if (typeof nextConfig.webpack === 'function') {
52
+ return nextConfig.webpack(config, options);
53
+ }
54
+
55
+ return config;
56
+ }
57
+
58
+ });
59
+
60
+ exports.createVanillaExtractPlugin = createVanillaExtractPlugin;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./vanilla-extract-next-plugin.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./vanilla-extract-next-plugin.cjs.dev.js");
7
+ }
@@ -0,0 +1,60 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var webpackPlugin = require('@vanilla-extract/webpack-plugin');
6
+ var browserslist = require('browserslist');
7
+ var css = require('next/dist/build/webpack/config/blocks/css');
8
+ var loaders = require('next/dist/build/webpack/config/blocks/css/loaders');
9
+
10
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
11
+
12
+ var browserslist__default = /*#__PURE__*/_interopDefault(browserslist);
13
+
14
+ function getSupportedBrowsers(dir, isDevelopment) {
15
+ let browsers;
16
+
17
+ try {
18
+ browsers = browserslist__default["default"].loadConfig({
19
+ path: dir,
20
+ env: isDevelopment ? 'development' : 'production'
21
+ });
22
+ } catch {}
23
+
24
+ return browsers;
25
+ }
26
+
27
+ const createVanillaExtractPlugin = (pluginOptions = {}) => (nextConfig = {}) => Object.assign({}, nextConfig, {
28
+ webpack(config, options) {
29
+ const {
30
+ dir,
31
+ dev,
32
+ isServer
33
+ } = options;
34
+ const cssRules = config.module.rules.find(rule => Array.isArray(rule.oneOf) && rule.oneOf.some(({
35
+ test
36
+ }) => typeof test === 'object' && typeof test.test === 'function' && test.test('filename.css'))).oneOf;
37
+ cssRules.unshift({
38
+ test: /\.vanilla\.css$/i,
39
+ sideEffects: true,
40
+ use: loaders.getGlobalCssLoader({
41
+ assetPrefix: config.assetPrefix,
42
+ isClient: !isServer,
43
+ isServer,
44
+ isDevelopment: dev,
45
+ future: nextConfig.future || {},
46
+ experimental: nextConfig.experimental || {}
47
+ }, () => css.lazyPostCSS(dir, getSupportedBrowsers(dir, dev)), [])
48
+ });
49
+ config.plugins.push(new webpackPlugin.VanillaExtractPlugin(pluginOptions));
50
+
51
+ if (typeof nextConfig.webpack === 'function') {
52
+ return nextConfig.webpack(config, options);
53
+ }
54
+
55
+ return config;
56
+ }
57
+
58
+ });
59
+
60
+ exports.createVanillaExtractPlugin = createVanillaExtractPlugin;
@@ -0,0 +1,52 @@
1
+ import { VanillaExtractPlugin } from '@vanilla-extract/webpack-plugin';
2
+ import browserslist from 'browserslist';
3
+ import { lazyPostCSS } from 'next/dist/build/webpack/config/blocks/css';
4
+ import { getGlobalCssLoader } from 'next/dist/build/webpack/config/blocks/css/loaders';
5
+
6
+ function getSupportedBrowsers(dir, isDevelopment) {
7
+ let browsers;
8
+
9
+ try {
10
+ browsers = browserslist.loadConfig({
11
+ path: dir,
12
+ env: isDevelopment ? 'development' : 'production'
13
+ });
14
+ } catch {}
15
+
16
+ return browsers;
17
+ }
18
+
19
+ const createVanillaExtractPlugin = (pluginOptions = {}) => (nextConfig = {}) => Object.assign({}, nextConfig, {
20
+ webpack(config, options) {
21
+ const {
22
+ dir,
23
+ dev,
24
+ isServer
25
+ } = options;
26
+ const cssRules = config.module.rules.find(rule => Array.isArray(rule.oneOf) && rule.oneOf.some(({
27
+ test
28
+ }) => typeof test === 'object' && typeof test.test === 'function' && test.test('filename.css'))).oneOf;
29
+ cssRules.unshift({
30
+ test: /\.vanilla\.css$/i,
31
+ sideEffects: true,
32
+ use: getGlobalCssLoader({
33
+ assetPrefix: config.assetPrefix,
34
+ isClient: !isServer,
35
+ isServer,
36
+ isDevelopment: dev,
37
+ future: nextConfig.future || {},
38
+ experimental: nextConfig.experimental || {}
39
+ }, () => lazyPostCSS(dir, getSupportedBrowsers(dir, dev)), [])
40
+ });
41
+ config.plugins.push(new VanillaExtractPlugin(pluginOptions));
42
+
43
+ if (typeof nextConfig.webpack === 'function') {
44
+ return nextConfig.webpack(config, options);
45
+ }
46
+
47
+ return config;
48
+ }
49
+
50
+ });
51
+
52
+ export { createVanillaExtractPlugin };
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@vanilla-extract/next-plugin",
3
+ "version": "0.0.0-alternative-webpack-loader-20228910529",
4
+ "description": "Zero-runtime Stylesheets-in-TypeScript",
5
+ "main": "dist/vanilla-extract-next-plugin.cjs.js",
6
+ "module": "dist/vanilla-extract-next-plugin.esm.js",
7
+ "files": [
8
+ "/dist"
9
+ ],
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/seek-oss/vanilla-extract.git",
13
+ "directory": "packages/next-plugin"
14
+ },
15
+ "author": "SEEK",
16
+ "license": "MIT",
17
+ "dependencies": {
18
+ "@vanilla-extract/webpack-plugin": "^0.0.0-alternative-webpack-loader-20228910529",
19
+ "browserslist": "^4.19.1"
20
+ },
21
+ "peerDependencies": {
22
+ "next": ">=12.0.5"
23
+ },
24
+ "devDependencies": {
25
+ "next": "^12.0.5"
26
+ }
27
+ }