-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtailwind-script.js
More file actions
95 lines (78 loc) · 2.81 KB
/
Copy pathtailwind-script.js
File metadata and controls
95 lines (78 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Import necessary modules
import { execSync } from 'child_process'; // For running shell commands
import fs from 'fs'; // For file system operations
import { fileURLToPath } from 'url'; // For converting import.meta.url to a file path
import path from 'path'; // For working with file paths
// Get the current module's file path
const __filename = fileURLToPath(import.meta.url);
// Get the directory name of the current module's file path
const __dirname = path.dirname(__filename);
try {
// Check if Tailwind CSS is already installed
execSync('npm ls tailwindcss', { stdio: 'ignore' });
console.log('Tailwind CSS is already installed.');
} catch (error) {
// If Tailwind CSS is not installed, install it and its dependencies
execSync('npm install -D tailwindcss postcss autoprefixer', { stdio: 'inherit' });
}
// Initialize a Tailwind CSS configuration file
execSync('npx tailwindcss init -p', { stdio: 'inherit' });
// Create a CSS file to include Tailwind's styles
const stylesDir = path.join(__dirname, 'src');
const tailwindCSSFile = path.join(stylesDir, 'index.css');
const cssCode = `@tailwind base;
@tailwind components;
@tailwind utilities;
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
width: 100vw;
height: 100vh;
scroll-behavior: smooth;
}
`;
const tailwindConfigCode = `module.exports = {
content: ["./src/**/*.{js,jsx,ts,tsx}"],
theme: {
extend: {
colors: {
},
fontFamily: {
},
fontSize: {
'xs': ['0.75rem', '1rem'], // Example: Extra small screens
'sm': ['0.875rem', '1.25rem'], // Example: Small screens
'base': ['1rem', '1.5rem'], // Example: Medium screens
'lg': ['1.125rem', '1.75rem'], // Example: Large screens
'xl': ['1.25rem', '2rem'], // Example: Extra large screens
'2xl': ['1.5rem', '2.25rem'], // Example: 2X large screens
'3xl': ['1.875rem', '2.5rem'], // Example: 3X large screens
'4xl': ['2.25rem', '3rem'], // Example: 4X large screens
'5xl': ['3rem', '1'], // Example: 5X large screens
'6xl': ['4rem', '1'],
},
container: {
center: true,
padding: {
DEFAULT: '1rem',
sm: '2rem',
lg: '4rem',
xl: '5rem',
'2xl': '6rem',
},
},
},
},
plugins: [],
};`
// Write the necessary Tailwind CSS imports to the CSS file
fs.writeFileSync(tailwindCSSFile, cssCode);
const tailwindConfigFile = path.join(__dirname, 'tailwind.config.js');
fs.writeFileSync(tailwindConfigFile, tailwindConfigCode);
console.log("Tailwind Config Code Done Successfully!!!!!")
console.log('Tailwind CSS has been successfully set up in your React Vite project.');
// Start the development server
// execSync('npm run dev', { stdio: 'inherit' });