Skip to content

Commit

Permalink
Merge pull request #1381 from RoundingWell/vite-v6
Browse files Browse the repository at this point in the history
Update Vite version to v6
  • Loading branch information
paulfalgout authored Jan 14, 2025
2 parents 4582fb3 + e3d501f commit 1d3a741
Show file tree
Hide file tree
Showing 8 changed files with 280 additions and 268 deletions.
5 changes: 4 additions & 1 deletion config/vite-plugin-handlebars-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function viteHbsPlugin(hbsOptions = {}) {
hbsCode = await fs.promises.readFile(id, 'utf8');
} catch (exception) {
console.warn(`${ id } couldn't be loaded by ${ VITE_PLUGIN_NAME }: `, exception);
return;
return null;
}
try {
const compiledHbs = Handlebars.precompile(hbsCode, hbsOptions);
Expand All @@ -27,8 +27,11 @@ export default function viteHbsPlugin(hbsOptions = {}) {
`;
} catch (exception) {
console.error(`${ id } errored during Handlebars compiling: `, exception);
return null;
}
}

return null;
},
};
}
28 changes: 28 additions & 0 deletions config/vite-plugin-yaml.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { load } from 'js-yaml';

const yamlExtension = /\.ya?ml$/;

export default function() {
return {
name: 'vite-plugin-yaml',
async transform(code, id) {
if (yamlExtension.test(id)) {
try {
const yamlData = load(code, {
filename: id,
});

return {
code: `const data = ${ JSON.stringify(yamlData) };\nexport default data;`,
map: { mappings: '' },
};
} catch (exception) {
console.error(`${ id } errored during yaml processing: `, exception);
return null;
}
}

return null;
},
};
}
Loading

0 comments on commit 1d3a741

Please sign in to comment.