Skip to content

Commit

Permalink
README and functional usage
Browse files Browse the repository at this point in the history
  • Loading branch information
cadenmarinozzi committed Feb 16, 2024
1 parent 10b80e3 commit 9f939cc
Show file tree
Hide file tree
Showing 29 changed files with 18,929 additions and 2 deletions.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Scraipt easily integrates with your code's compilation process and optimizes eac
- [Webpack](#webpack)
- [create-react-app](#create-react-app)
- [Configuration](#configuration)
- [Functional Usage][#functional-usage]
- [Ignoring Functions](#ignoring-functions)
- [Building](#building)
- [Testing](#testing)
Expand Down Expand Up @@ -191,10 +192,48 @@ module.exports = {
- Example: `true`

- `buildPath <Array>`

- The path to write the optimized debug code to.
- Default: `dist`
- Example: `build`

## Functional Usage

Scraipt can also be used easily with a functional approach. To do so, import `useScraipt` from the `scraipt` library and call it with your webpack configuration.

`useScraipt(webpackConfig <optional Object>, options <optional Object>, framework <optional String>) => WebpackConfig`

- `webpackConfig <optional Object>`

- Your webpack configuration.
- Default: `{}`

- `options <optional Object>`

- The options to use with Scraipt. See [Configuration](#configuration) for a list of available options.
- Default: `{}`

- `framework <optional String>`

- Can be `React`, or `webpack`.
- The framework you are using. Scraipt will try and automatically detect the framework you are using from the provided config, however, if it cannot, you can pass the framework as the third argument.
- Default: Autodetect

### Example

```javascript
const { useScraipt } = require('scraipt');

module.exports = useScraipt(
{
// ... Your webpack configuration
},
{
model: 'gpt-3.5-turbo',
}
);
```

## Ignoring Functions

If you would like to ignore a function from being optimized, add the following comment to the top of the function:
Expand Down
6 changes: 6 additions & 0 deletions site/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"baseUrl": "src"
},
"include": ["src"]
}
Loading

0 comments on commit 9f939cc

Please sign in to comment.