Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/open-southeners/laravel-mix-swc
Integrate SWC JavaScript/TypeScript compiler with Laravel Mix
https://github.com/open-southeners/laravel-mix-swc
laravel laravel-mix laravel-mix-extension rust swc typescript
Last synced: about 1 month ago
JSON representation
Integrate SWC JavaScript/TypeScript compiler with Laravel Mix
- Host: GitHub
- URL: https://github.com/open-southeners/laravel-mix-swc
- Owner: open-southeners
- License: mit
- Created: 2022-05-04T12:15:35.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-10T10:40:49.000Z (over 2 years ago)
- Last Synced: 2024-08-09T04:38:03.657Z (5 months ago)
- Topics: laravel, laravel-mix, laravel-mix-extension, rust, swc, typescript
- Language: JavaScript
- Homepage:
- Size: 47.9 KB
- Stars: 10
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Laravel Mix SWC
[![npm](https://img.shields.io/npm/v/laravel-mix-swc)](https://www.npmjs.com/package/laravel-mix-swc) [![npm](https://img.shields.io/npm/dm/laravel-mix-swc)](https://www.npmjs.com/package/laravel-mix-swc)
Integrate SWC JavaScript compiler with Laravel Mix.
We know how far Rust can be in terms of performance, this projects brings all its power for JavaScript compiling (**doing all the job that Babel does but much faster!**).
[**Check its benchmarks here for more reference.**](https://swc.rs/docs/benchmarks)
## Getting started
Installing this in your Laravel project is very simple, run this command:
```sh
yarn add -D laravel-mix-swc
# or
npm i --dev laravel-mix-swc
```And in your `webpack.mix.js` file in the root of your project add the following:
```js
// At the very top of your file:
require("laravel-mix-swc");// And replace mix.ts(), mix.js() or mix.babel() with .swc():
mix.swc("resources/js/app.js", "public/js")
```## Configuration
To configure SWC you can send options as third parameter:
```js
mix.swc("resources/js/app.js", "public/js", {
jsc: {
parser: {
syntax: "ecmascript",
jsx: false,
}
}
})
```[**For more info check the official documentation of swc here.**](https://swc.rs/docs/configuration/compilation)
### Config tips
Some "presets" or lets call them like that, remember this is the default config: https://github.com/open-southeners/laravel-mix-swc/blob/e45a3f1b92a1130a1acda2de7801f1348df547b7/src/plugin.js#L6
#### TypeScript with JavaScript
```json
{
"test": ".*.ts$",
"jsc": {
"parser": {
"syntax": "typescript"
}
}
}
```#### JSX support
```json
{
"jsc": {
"parser": {
"jsx": true
}
}
}
```#### Vue support
Very important that you've the decorators enabled, this also supports TypeScript but you can modify that.
```json
{
"test": ".*.ts$",
"jsc": {
"parser": {
"syntax": "typescript",
"jsx": false,
"decorators": true,
"dynamicImport": true,
"exportDefaultFrom": true
}
}
}
```## License
This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).