├── .gitignore ├── .swcrc ├── LICENSE.md ├── README.md ├── package-lock.json ├── package.json ├── public └── index.html ├── src ├── components │ ├── App.js │ ├── app.css │ └── sample.jpg └── index.js └── webpack.config.js /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | dist 3 | node_modules 4 | -------------------------------------------------------------------------------- /.swcrc: -------------------------------------------------------------------------------- 1 | { 2 | "jsc": { 3 | "parser": { 4 | "syntax": "ecmascript", 5 | "jsx": true, 6 | "numericSeparator": false, 7 | "classPrivateProperty": false, 8 | "privateMethod": false, 9 | "classProperty": false, 10 | "functionBind": false, 11 | "decorators": false, 12 | "decoratorsBeforeExport": false 13 | }, 14 | "transform": { 15 | "react": { 16 | "pragma": "React.createElement", 17 | "pragmaFrag": "React.Fragment", 18 | "throwIfNamespace": true, 19 | "development": false, 20 | "useBuiltins": false 21 | }, 22 | "optimizer": { 23 | "globals": { 24 | "vars": { 25 | "__DEBUG__": "true" 26 | } 27 | } 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright 2019 Luke Geneva 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SWC React Template 2 | 3 | A template for quickly getting a React project up and running using the SWC compiler. 4 | 5 | ## Installing 6 | 7 | Please refer to the [installation](https://swc-project.github.io/docs/installation) section of the SWC project [website](https://swc-project.github.io). It contains appropriate installation instructions based on the operating system you are using. 8 | 9 | ## Getting Started 10 | 11 | Start by cloning this repository. 12 | 13 | ```bash 14 | git clone https://github.com/LukeGeneva/swc-react-template.git 15 | cd 16 | ``` 17 | 18 | Remove the `.git` directory and then initialize your own. 19 | 20 | ```bash 21 | rm -rf .git 22 | git init 23 | ``` 24 | 25 | You can alter the `package.json` file to suit your needs. This may be as simple as running: 26 | 27 | ```bash 28 | npm init 29 | ``` 30 | 31 | Install packages 32 | 33 | ```bash 34 | npm install 35 | ``` 36 | 37 | The template uses [webpack](https://webpack.js.org/) and comes packaged with `webpack-dev-server`. You can start the dev server by running: 38 | 39 | ```bash 40 | npm start 41 | ``` 42 | 43 | ## Contributing 44 | 45 | PRs welcome! :smiley: 46 | 47 | ## License 48 | 49 | This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details 50 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "swc-react-template", 3 | "version": "1.0.0", 4 | "description": "a create react app made with swc!", 5 | "main": "index.js", 6 | "scripts": { 7 | "build": "swc src -d build", 8 | "start": "webpack-dev-server --open", 9 | "test": "echo \"Error: no test specified\" && exit 1" 10 | }, 11 | "author": "", 12 | "license": "MIT", 13 | "dependencies": { 14 | "react": "^17.0.2", 15 | "react-dom": "^17.0.2" 16 | }, 17 | "devDependencies": { 18 | "@swc/cli": "^0.1.55", 19 | "@swc/core": "^1.2.121", 20 | "css-loader": "^6.5.1", 21 | "html-webpack-plugin": "^5.5.0", 22 | "style-loader": "^3.3.1", 23 | "swc-loader": "^0.1.15", 24 | "webpack": "^5.65.0", 25 | "webpack-cli": "^4.9.1", 26 | "webpack-dev-server": "^4.6.0" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | SWC Demo 10 | 11 | 12 | 13 | 14 |
15 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/components/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import './app.css'; 3 | 4 | const App = () => { 5 | return ( 6 | <> 7 |

App is running!

8 |
9 | 10 | ); 11 | }; 12 | 13 | export default App; 14 | -------------------------------------------------------------------------------- /src/components/app.css: -------------------------------------------------------------------------------- 1 | /* sample styles */ 2 | 3 | * { 4 | margin: 0; 5 | padding: 0; 6 | box-sizing: border-box; 7 | } 8 | 9 | .check-img { 10 | width: 100%; 11 | height: 100vh; 12 | background-image: url('../components/sample.jpg'); 13 | background-position: center; 14 | background-size: cover; 15 | } 16 | 17 | h1 { 18 | color: orangered; 19 | text-align: center; 20 | } 21 | -------------------------------------------------------------------------------- /src/components/sample.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LukeGeneva/swc-react-template/1cfe0329ea09e207be2d3b26a7c88432d564c3a5/src/components/sample.jpg -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom"; 3 | import App from "./components/App"; 4 | 5 | ReactDOM.render(, document.getElementById("root")); 6 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const HtmlWebpackPlugin = require('html-webpack-plugin'); 3 | 4 | module.exports = { 5 | mode: 'development', 6 | entry: './src/index.js', 7 | module: { 8 | rules: [ 9 | { 10 | test: /\.(js|jsx)$/, 11 | exclude: /(node_modules|bower_components)/, 12 | use: { 13 | // `.swcrc` can be used to configure swc 14 | loader: 'swc-loader', 15 | }, 16 | }, 17 | { 18 | test: /\.css$/, 19 | use: ['style-loader', 'css-loader'], 20 | }, 21 | { 22 | test: /\.(jpe?g|gif|png|svg)/, 23 | type: 'asset/resource', 24 | }, 25 | ], 26 | }, 27 | plugins: [ 28 | new HtmlWebpackPlugin({ 29 | template: path.join(__dirname, 'public/index.html'), 30 | }), 31 | ], 32 | devServer: { 33 | //contentBase: path.join(__dirname, "dist"), 34 | port: 3000, 35 | liveReload: true, 36 | }, 37 | }; 38 | --------------------------------------------------------------------------------