Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jycouet committed Jan 23, 2025
1 parent 84b80b8 commit 01ba71c
Showing 1 changed file with 5 additions and 93 deletions.
98 changes: 5 additions & 93 deletions packages/addons/tailwindcss/index.ts
Original file line number Diff line number Diff line change
@@ -1,111 +1,23 @@
import { defineAddon, defineAddonOptions } from '@sveltejs/cli-core';
import { defineAddon } from '@sveltejs/cli-core';
import { addImports } from '@sveltejs/cli-core/css';
import { array, common, exports, imports, object } from '@sveltejs/cli-core/js';
import { parseCss, parseScript, parseJson, parseSvelte } from '@sveltejs/cli-core/parsers';
import { imports } from '@sveltejs/cli-core/js';
import { parseCss, parseJson, parseSvelte } from '@sveltejs/cli-core/parsers';
import { addSlot } from '@sveltejs/cli-core/html';

// type Plugin = {
// id: string;
// package: string;
// version: string;
// identifier: string;
// };

// const plugins: Plugin[] = [
// {
// id: 'typography',
// package: '@tailwindcss/typography',
// version: '^0.5.16',
// identifier: 'typography'
// },
// {
// id: 'forms',
// package: '@tailwindcss/forms',
// version: '^0.5.10',
// identifier: 'forms'
// },
// {
// id: 'container-queries',
// package: '@tailwindcss/container-queries',
// version: '^0.1.1',
// identifier: 'containerQueries'
// }
// ];

const options = defineAddonOptions({
// plugins: {
// type: 'multiselect',
// question: 'Which plugins would you like to add?',
// options: plugins.map((p) => ({ value: p.id, label: p.id, hint: p.package })),
// default: []
// }
});

export default defineAddon({
id: 'tailwindcss',
alias: 'tailwind',
shortDescription: 'css framework',
homepage: 'https://tailwindcss.com',
options,
run: ({ sv, options, typescript, kit, dependencyVersion }) => {
const ext = typescript ? 'ts' : 'js';
options: {},
run: ({ sv, typescript, kit, dependencyVersion }) => {
const prettierInstalled = Boolean(dependencyVersion('prettier'));

sv.devDependency('@tailwindcss/vite', '^4.0.0');
sv.devDependency('tailwindcss', '^4.0.0');

if (prettierInstalled) sv.devDependency('prettier-plugin-tailwindcss', '^0.6.11');

// sv.file(`tailwind.config.${ext}`, (content) => {
// const { ast, generateCode } = parseScript(content);
// let root;
// const rootExport = object.createEmpty();
// if (typescript) {
// imports.addNamed(ast, 'tailwindcss', { Config: 'Config' }, true);
// root = common.satisfiesExpression(rootExport, 'Config');
// }

// const { astNode: exportDeclaration, value: node } = exports.defaultExport(
// ast,
// root ?? rootExport
// );

// const config = node.type === 'TSSatisfiesExpression' ? node.expression : node;
// if (config.type !== 'ObjectExpression') {
// throw new Error(`Unexpected tailwind config shape: ${config.type}`);
// }

// if (!typescript) {
// common.addJsDocTypeComment(exportDeclaration, "import('tailwindcss').Config");
// }

// const contentArray = object.property(config, 'content', array.createEmpty());
// array.push(contentArray, './src/**/*.{html,js,svelte,ts}');

// const themeObject = object.property(config, 'theme', object.createEmpty());
// object.property(themeObject, 'extend', object.createEmpty());

// const pluginsArray = object.property(config, 'plugins', array.createEmpty());

// for (const plugin of plugins) {
// if (!options.plugins.includes(plugin.id)) continue;
// imports.addDefault(ast, plugin.package, plugin.identifier);
// array.push(pluginsArray, { type: 'Identifier', name: plugin.identifier });
// }

// return generateCode();
// });

// sv.file('postcss.config.js', (content) => {
// const { ast, generateCode } = parseScript(content);
// const { value: rootObject } = exports.defaultExport(ast, object.createEmpty());
// const pluginsObject = object.property(rootObject, 'plugins', object.createEmpty());

// object.property(pluginsObject, 'tailwindcss', object.createEmpty());
// object.property(pluginsObject, 'autoprefixer', object.createEmpty());
// return generateCode();
// });

sv.file('src/app.css', (content) => {
const layerImports = ['tailwindcss'];
if (layerImports.every((i) => content.includes(i))) {
Expand Down

0 comments on commit 01ba71c

Please sign in to comment.