-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: update readme for nextjs and webpack plugin (#167)
- Loading branch information
1 parent
f968076
commit 7ddea49
Showing
2 changed files
with
112 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,49 @@ | ||
# @stylexjs/nextjs-plugin | ||
|
||
... | ||
## Documentation Website | ||
[https://stylexjs.com](https://stylexjs.com) | ||
|
||
## Installation | ||
|
||
Install the package by using: | ||
```bash | ||
npm install --save-dev @stylexjs/nextjs-plugin | ||
``` | ||
|
||
or with yarn: | ||
|
||
```bash | ||
yarn add --dev @stylexjs/nextjs-plugin | ||
``` | ||
|
||
> :warning: `@/` alias is unsupported at the moment. | ||
Add the following to your `.babelrc.js` | ||
```javascript | ||
module.exports = { | ||
presets: ['next/babel'], | ||
plugins: [ | ||
[ | ||
'@stylexjs/babel-plugin', | ||
{ | ||
dev: process.env.NODE_ENV === 'development', | ||
runtimeInjection: false, | ||
genConditionalClasses: true, | ||
unstable_moduleResolution: { | ||
type: 'commonJS', | ||
rootDir: __dirname, | ||
}, | ||
}, | ||
], | ||
], | ||
}; | ||
``` | ||
|
||
Add the following to your `next.config.js` | ||
```javascript | ||
const stylexPlugin = require('@stylexjs/nextjs-plugin'); | ||
|
||
module.exports = stylexPlugin({ | ||
rootDir: __dirname, | ||
})({}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,67 @@ | ||
# @stylexjs/webpack-plugin | ||
|
||
... | ||
|
||
## Documentation Website | ||
[https://stylexjs.com](https://stylexjs.com) | ||
|
||
## Installation | ||
|
||
Install the package by using: | ||
```bash | ||
npm install --save-dev @stylexjs/webpack-plugin | ||
``` | ||
|
||
or with yarn: | ||
|
||
```bash | ||
yarn add --dev @stylexjs/webpack-plugin | ||
``` | ||
|
||
Add the following to your `webpack.config.js` | ||
```javascript | ||
const StylexPlugin = require('@stylexjs/webpack-plugin'); | ||
const path = require('path'); | ||
|
||
const config = (env, argv) => ({ | ||
entry: { | ||
main: './src/index.js', | ||
}, | ||
output: { | ||
path: path.resolve(__dirname, '.build'), | ||
filename: '[name].js', | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
use: 'babel-loader', | ||
}, | ||
], | ||
}, | ||
plugins: [ | ||
// Ensure that the stylex plugin is used before Babel | ||
new StylexPlugin({ | ||
filename: 'styles.[contenthash].css', | ||
// get webpack mode and set value for dev | ||
dev: argv.mode === 'development', | ||
// Use statically generated CSS files and not runtime injected CSS. | ||
// Even in development. | ||
runtimeInjection: false, | ||
// optional. default: 'x' | ||
classNamePrefix: 'x', | ||
// Required for CSS variable support | ||
unstable_moduleResolution: { | ||
// type: 'commonJS' | 'haste' | ||
// default: 'commonJS' | ||
type: 'commonJS', | ||
// The absolute path to the root directory of your project | ||
rootDir: __dirname, | ||
}, | ||
}), | ||
], | ||
cache: true, | ||
}); | ||
|
||
module.exports = config; | ||
``` |