24
loading...
This website collects cookies to deliver better user experience
npx create-react-app --template typescript cra-template-tailwind-twin-goober
// package.json
...
"cleanup-template": "rm -rf ./_template_",
"generate-dirs": "mkdir _template_ && cd _template_ && mkdir template && cd template && mkdir src && mkdir public && cd .. && cd ..",
"copy-resources": "cp -a ./src/. _template_/template/src && cp -a ./public/. _template_/template/public && cp template.json _template_/ && cp template-package.json _template_/package.json && cp .gitignore _template_/template/gitignore",
"generate-template": "npm run cleanup-template && npm run generate-dirs && npm run copy-resources"
...
// generates template
npm run generate-template
// creates a new react app with your custom template
npx create-react-app --template=file:/path/to/your/dir/cra-template-tailwind-twin-goober/_template_
npm i eslint -g
npx eslint --init
…
"copy-resources": "cp -a ./src/. _template_/template/src && cp -a ./public/. _template_/template/public && cp template.json _template_/ && cp template-package.json _template_/package.json && cp .gitignore _template_/template/gitignore && cp .eslintrc.json _template_/template/",
...
npm install -D prettier
...
"copy-resources": "cp -a ./src/. _template_/template/src && cp -a ./public/. _template_/template/public && cp template.json _template_/ && cp template-package.json _template_/package.json && cp .gitignore _template_/template/gitignore && cp ./{.eslintrc.json,.prettierrc.json} _template_/template/ ",
...
npm i -D husky lint-staged
...
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"./src/**/*.{ts,js,jsx,tsx}": [
"npm run lint --fix",
"npm run format"
]
},
...
npm install -D tailwindcss@npm:@tailwindcss/postcss7-compat postcss@^7 autoprefixer@^9
npm i @craco/craco
...
"start": "craco start",
"build": "craco build",
"test": "craco test",
"eject": "react-scripts eject",
...
// craco.config.js
module.exports = {
style: {
postcss: {
plugins: [
require('tailwindcss'),
require('autoprefixer'),
],
},
},
}
npx tailwindcss-cli@latest init
...
"copy-resources": "cp -a ./src/. _template_/template/src && cp -a ./public/. _template_/template/public && cp template.json _template_/ && cp template-package.json _template_/package.json && cp .gitignore _template_/template/gitignore && cp ./{.eslintrc.json,.prettierrc.json,craco.config.js,tailwind.config.js} _template_/template/ ",
...
npm i twin.macro
npm i -D babel-plugin-macros @babel/core @agney/babel-plugin-goober-css-prop babel-plugin-twin
npm i goober
...
"babelMacros": {
"twin": {
"config": "tailwind.config.js",
"preset": "goober"
}
}
...
// .babelrc.json
module.exports = {
plugins: [
'@agney/babel-plugin-goober-css-prop',
'babel-plugin-macros',
'babel-plugin-twin',
],
};
...
"copy-resources": "cp -a ./src/. _template_/template/src && cp -a ./public/. _template_/template/public && cp template.json _template_/ && cp template-package.json _template_/package.json && cp .gitignore _template_/template/gitignore && cp ./{.eslintrc.json,.prettierrc.json,craco.config.js,tailwind.config.js,babel.config.json} _template_/template/ ",",
...
import React from 'react';
import ReactDOM from 'react-dom';
import { setup } from 'goober';
import 'tailwindcss/dist/base.min.css';
import App from './App';
// setup goober
setup(React.createElement);
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
npm login
npm publish --access public