@vanilla-extract/next-plugin 1.0.1 → 2.0.0
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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 SEEK
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -82,7 +82,6 @@ Want to work at a higher level while maximising style re-use? Check out 🍨 [S
|
|
|
82
82
|
- [webpack](#webpack)
|
|
83
83
|
- [esbuild](#esbuild)
|
|
84
84
|
- [Vite](#vite)
|
|
85
|
-
- [Snowpack](#snowpack)
|
|
86
85
|
- [Next.js](#nextjs)
|
|
87
86
|
- [Gatsby](#gatsby)
|
|
88
87
|
- [Test environments](#test-environments)
|
|
@@ -95,6 +94,7 @@ Want to work at a higher level while maximising style re-use? Check out 🍨 [S
|
|
|
95
94
|
- [createTheme](#createtheme)
|
|
96
95
|
- [createGlobalTheme](#createglobaltheme)
|
|
97
96
|
- [createThemeContract](#createthemecontract)
|
|
97
|
+
- [createGlobalThemeContract](#createglobalthemecontract)
|
|
98
98
|
- [assignVars](#assignvars)
|
|
99
99
|
- [createVar](#createvar)
|
|
100
100
|
- [fallbackVar](#fallbackvar)
|
|
@@ -271,27 +271,6 @@ export default {
|
|
|
271
271
|
|
|
272
272
|
> Please note: There are currently no automatic readable class names during development. However, you can still manually provide a debug ID as the last argument to functions that generate scoped styles, e.g. `export const className = style({ ... }, 'className');`
|
|
273
273
|
|
|
274
|
-
### Snowpack
|
|
275
|
-
|
|
276
|
-
1. Install the dependencies.
|
|
277
|
-
|
|
278
|
-
```bash
|
|
279
|
-
npm install @vanilla-extract/css @vanilla-extract/snowpack-plugin
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
2. Add the [Snowpack](https://www.snowpack.dev/) plugin to your snowpack config.
|
|
283
|
-
|
|
284
|
-
> 💡 This plugin accepts an optional [configuration object](#configuration).
|
|
285
|
-
|
|
286
|
-
```js
|
|
287
|
-
// snowpack.config.json
|
|
288
|
-
{
|
|
289
|
-
"plugins": ["@vanilla-extract/snowpack-plugin"]
|
|
290
|
-
}
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
> Please note: There are currently no automatic readable class names during development. However, you can still manually provide a debug ID as the last argument to functions that generate scoped styles, e.g. `export const className = style({ ... }, 'className');`
|
|
294
|
-
|
|
295
274
|
### Next.js
|
|
296
275
|
|
|
297
276
|
1. Install the dependencies.
|
|
@@ -300,16 +279,7 @@ npm install @vanilla-extract/css @vanilla-extract/snowpack-plugin
|
|
|
300
279
|
npm install @vanilla-extract/css @vanilla-extract/babel-plugin @vanilla-extract/next-plugin
|
|
301
280
|
```
|
|
302
281
|
|
|
303
|
-
2. If you don't have a
|
|
304
|
-
|
|
305
|
-
```json
|
|
306
|
-
{
|
|
307
|
-
"presets": ["next/babel"],
|
|
308
|
-
"plugins": ["@vanilla-extract/babel-plugin"]
|
|
309
|
-
}
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
3. If you don't have a `next.config.js` file in the root of your project, create one. Add the [Next.js](https://nextjs.org) plugin to your `next.config.js` file.
|
|
282
|
+
2. If you don't have a `next.config.js` file in the root of your project, create one. Add the [Next.js](https://nextjs.org) plugin to your `next.config.js` file.
|
|
313
283
|
|
|
314
284
|
> 💡 This plugin accepts an optional [configuration object](#configuration).
|
|
315
285
|
|
|
@@ -319,6 +289,7 @@ const {
|
|
|
319
289
|
} = require('@vanilla-extract/next-plugin');
|
|
320
290
|
const withVanillaExtract = createVanillaExtractPlugin();
|
|
321
291
|
|
|
292
|
+
/** @type {import('next').NextConfig} */
|
|
322
293
|
const nextConfig = {};
|
|
323
294
|
|
|
324
295
|
module.exports = withVanillaExtract(nextConfig);
|
|
@@ -336,11 +307,25 @@ const withMDX = require('@next/mdx')({
|
|
|
336
307
|
extension: /\.mdx$/
|
|
337
308
|
});
|
|
338
309
|
|
|
310
|
+
/** @type {import('next').NextConfig} */
|
|
339
311
|
const nextConfig = {};
|
|
340
312
|
|
|
341
313
|
module.exports = withVanillaExtract(withMDX(nextConfig));
|
|
342
314
|
```
|
|
343
315
|
|
|
316
|
+
3. (Optional) If you want to automatically generate debug IDs during development, you can add the [Babel](https://babeljs.io) plugin. Note that this step will cause Next.js to switch from [SWC](https://github.com/swc-project/swc) to Babel, increasing build times. This may or may not be an issue depending on the size of your project.
|
|
317
|
+
|
|
318
|
+
> Note: While optional for Next.js, the Babel plugin is still required when trying to run `.css.ts` files in Node for unit testing since the files are no longer being processed by a bundler.
|
|
319
|
+
|
|
320
|
+
If you don't have a `.babelrc` file in the root of your project, create one. Add the Babel plugin to your `.babelrc` file, ensuring that you're also including `"next/babel"` in your `presets` array.
|
|
321
|
+
|
|
322
|
+
```json
|
|
323
|
+
{
|
|
324
|
+
"presets": ["next/babel"],
|
|
325
|
+
"plugins": ["@vanilla-extract/babel-plugin"]
|
|
326
|
+
}
|
|
327
|
+
```
|
|
328
|
+
|
|
344
329
|
### Gatsby
|
|
345
330
|
|
|
346
331
|
To add to your [Gatsby](https://www.gatsbyjs.com) site, use the [gatsby-plugin-vanilla-extract](https://github.com/KyleAMathews/gatsby-plugin-vanilla-extract) plugin.
|
|
@@ -3,11 +3,31 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var webpackPlugin = require('@vanilla-extract/webpack-plugin');
|
|
6
|
+
var browserslist = require('browserslist');
|
|
7
|
+
var css = require('next/dist/build/webpack/config/blocks/css');
|
|
6
8
|
var loaders = require('next/dist/build/webpack/config/blocks/css/loaders');
|
|
7
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
|
+
|
|
8
27
|
const createVanillaExtractPlugin = (pluginOptions = {}) => (nextConfig = {}) => Object.assign({}, nextConfig, {
|
|
9
28
|
webpack(config, options) {
|
|
10
29
|
const {
|
|
30
|
+
dir,
|
|
11
31
|
dev,
|
|
12
32
|
isServer
|
|
13
33
|
} = options;
|
|
@@ -24,7 +44,7 @@ const createVanillaExtractPlugin = (pluginOptions = {}) => (nextConfig = {}) =>
|
|
|
24
44
|
isDevelopment: dev,
|
|
25
45
|
future: nextConfig.future || {},
|
|
26
46
|
experimental: nextConfig.experimental || {}
|
|
27
|
-
},
|
|
47
|
+
}, () => css.lazyPostCSS(dir, getSupportedBrowsers(dir, dev)), [])
|
|
28
48
|
});
|
|
29
49
|
config.plugins.push(new webpackPlugin.VanillaExtractPlugin(pluginOptions));
|
|
30
50
|
|
|
@@ -3,11 +3,31 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var webpackPlugin = require('@vanilla-extract/webpack-plugin');
|
|
6
|
+
var browserslist = require('browserslist');
|
|
7
|
+
var css = require('next/dist/build/webpack/config/blocks/css');
|
|
6
8
|
var loaders = require('next/dist/build/webpack/config/blocks/css/loaders');
|
|
7
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
|
+
|
|
8
27
|
const createVanillaExtractPlugin = (pluginOptions = {}) => (nextConfig = {}) => Object.assign({}, nextConfig, {
|
|
9
28
|
webpack(config, options) {
|
|
10
29
|
const {
|
|
30
|
+
dir,
|
|
11
31
|
dev,
|
|
12
32
|
isServer
|
|
13
33
|
} = options;
|
|
@@ -24,7 +44,7 @@ const createVanillaExtractPlugin = (pluginOptions = {}) => (nextConfig = {}) =>
|
|
|
24
44
|
isDevelopment: dev,
|
|
25
45
|
future: nextConfig.future || {},
|
|
26
46
|
experimental: nextConfig.experimental || {}
|
|
27
|
-
},
|
|
47
|
+
}, () => css.lazyPostCSS(dir, getSupportedBrowsers(dir, dev)), [])
|
|
28
48
|
});
|
|
29
49
|
config.plugins.push(new webpackPlugin.VanillaExtractPlugin(pluginOptions));
|
|
30
50
|
|
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
import { VanillaExtractPlugin } from '@vanilla-extract/webpack-plugin';
|
|
2
|
+
import browserslist from 'browserslist';
|
|
3
|
+
import { lazyPostCSS } from 'next/dist/build/webpack/config/blocks/css';
|
|
2
4
|
import { getGlobalCssLoader } from 'next/dist/build/webpack/config/blocks/css/loaders';
|
|
3
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
|
+
|
|
4
19
|
const createVanillaExtractPlugin = (pluginOptions = {}) => (nextConfig = {}) => Object.assign({}, nextConfig, {
|
|
5
20
|
webpack(config, options) {
|
|
6
21
|
const {
|
|
22
|
+
dir,
|
|
7
23
|
dev,
|
|
8
24
|
isServer
|
|
9
25
|
} = options;
|
|
@@ -20,7 +36,7 @@ const createVanillaExtractPlugin = (pluginOptions = {}) => (nextConfig = {}) =>
|
|
|
20
36
|
isDevelopment: dev,
|
|
21
37
|
future: nextConfig.future || {},
|
|
22
38
|
experimental: nextConfig.experimental || {}
|
|
23
|
-
},
|
|
39
|
+
}, () => lazyPostCSS(dir, getSupportedBrowsers(dir, dev)), [])
|
|
24
40
|
});
|
|
25
41
|
config.plugins.push(new VanillaExtractPlugin(pluginOptions));
|
|
26
42
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vanilla-extract/next-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
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",
|
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
"author": "SEEK",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@vanilla-extract/webpack-plugin": "^2.0.0"
|
|
18
|
+
"@vanilla-extract/webpack-plugin": "^2.0.0",
|
|
19
|
+
"browserslist": "^4.19.1"
|
|
19
20
|
},
|
|
20
21
|
"peerDependencies": {
|
|
21
|
-
"next": ">=
|
|
22
|
+
"next": ">=12.0.5"
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|
|
24
|
-
"next": "^12.0.
|
|
25
|
+
"next": "^12.0.5"
|
|
25
26
|
}
|
|
26
|
-
}
|
|
27
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# @vanilla-extract/next-plugin
|
|
2
|
-
|
|
3
|
-
## 1.0.1
|
|
4
|
-
### Patch Changes
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
- [#443](https://github.com/seek-oss/vanilla-extract/pull/443) [`18363ee`](https://github.com/seek-oss/vanilla-extract/commit/18363ee319bf498ed97b068414f13f5383c41405) Thanks [@swudged](https://github.com/swudged)! - Support Next.js v12
|