Skip to content

Commit

Permalink
docs: update readme for nextjs and webpack plugin (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
aayushchugh authored Dec 14, 2023
1 parent f968076 commit 7ddea49
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 2 deletions.
48 changes: 47 additions & 1 deletion packages/nextjs-plugin/README.md
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,
})({});
```
66 changes: 65 additions & 1 deletion packages/webpack-plugin/README.md
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;
```

0 comments on commit 7ddea49

Please sign in to comment.