Skip to content

Commit d801b0e

Browse files
fix: insert the tailwindcss vite plugin at the start of the plugin array (#478)
* Fix plugin order * changeset * Add `unshift` to js tooling * Add test cases for `unshift` * format * tweaks * oops, fix --------- Co-authored-by: AdrianGonz97 <[email protected]>
1 parent a4e84c7 commit d801b0e

File tree

11 files changed

+67
-18
lines changed

11 files changed

+67
-18
lines changed

.changeset/big-chefs-return.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'sv': patch
3+
---
4+
5+
fix: insert the `tailwindcss` vite plugin at the start of the plugin array

packages/addons/tailwindcss/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default defineAddon({
6767

6868
const pluginsArray = object.property(param1, 'plugins', array.createEmpty());
6969
const pluginFunctionCall = functions.call(vitePluginName, []);
70-
array.push(pluginsArray, pluginFunctionCall);
70+
array.unshift(pluginsArray, pluginFunctionCall);
7171

7272
return generateCode();
7373
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const array = [
2+
{
3+
test2: 'string'
4+
},
5+
{
6+
test: true
7+
}
8+
];
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { array, object, common, variables } from '@sveltejs/cli-core/js';
2+
import type { ScriptFileEditor } from '@sveltejs/cli-core';
3+
4+
export function run({ ast }: ScriptFileEditor<any>): void {
5+
const array1 = array.createEmpty();
6+
7+
const object1 = object.create({ test: common.expressionFromString('true') });
8+
const object2 = object.create({ test2: common.createLiteral('string') });
9+
array.unshift(array1, object1);
10+
array.unshift(array1, object2);
11+
array.unshift(array1, object2); // avoid duplication
12+
13+
// create declaration so that we serialize everything
14+
const declaration = variables.declaration(ast, 'const', 'array', array1);
15+
ast.body.push(declaration);
16+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const array = ['test2', 'test'];
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { array, variables } from '@sveltejs/cli-core/js';
2+
import type { ScriptFileEditor } from '@sveltejs/cli-core';
3+
4+
export function run({ ast }: ScriptFileEditor<any>): void {
5+
const array1 = array.createEmpty();
6+
array.unshift(array1, 'test');
7+
array.unshift(array1, 'test2');
8+
array.unshift(array1, 'test'); // make sure items are not duplicated
9+
10+
// create declaration so that we serialize everything
11+
const declaration = variables.declaration(ast, 'const', 'array', array1);
12+
ast.body.push(declaration);
13+
}

0 commit comments

Comments
 (0)