@modyfi/vite-plugin-yaml
Advanced tools
Comparing version
@@ -27,2 +27,8 @@ import { Schema, YAMLException } from 'js-yaml'; | ||
/** | ||
* A boolean to determine if JSON object should be serialized. | ||
* | ||
* @see https://www.npmjs.com/package/tosource for the motivation behind serialization of JSON. | ||
*/ | ||
raw?: boolean; | ||
/** | ||
* A function that will be called for error reporting. | ||
@@ -39,2 +45,2 @@ * | ||
export { PluginOptions, _default as default }; | ||
export { type PluginOptions, _default as default }; |
@@ -20,3 +20,3 @@ // src/index.ts | ||
return { | ||
code: `const data = ${toSource(yamlData)}; | ||
code: `const data = ${options.raw ? yamlData : toSource(yamlData)}; | ||
export default data;`, | ||
@@ -23,0 +23,0 @@ map: { mappings: "" } |
{ | ||
"name": "@modyfi/vite-plugin-yaml", | ||
"version": "1.0.4", | ||
"version": "1.1.0", | ||
"description": "Import YAML files as JS objects ๐", | ||
@@ -12,2 +12,8 @@ "type": "module", | ||
"license": "MIT", | ||
"scripts": { | ||
"dev": "tsup --watch src", | ||
"example:dev": "pnpm -C example run dev", | ||
"example:build": "pnpm run build && pnpm -C example run build", | ||
"build": "tsup" | ||
}, | ||
"exports": { | ||
@@ -46,6 +52,6 @@ ".": { | ||
"peerDependencies": { | ||
"vite": "^2.6.0 || ^3.0.0 || ^4.0.0" | ||
"vite": "^3.2.7 || ^4.0.5 || ^5.0.5" | ||
}, | ||
"dependencies": { | ||
"@rollup/pluginutils": "5.0.2", | ||
"@rollup/pluginutils": "5.1.0", | ||
"js-yaml": "4.1.0", | ||
@@ -55,14 +61,8 @@ "tosource": "2.0.0-alpha.3" | ||
"devDependencies": { | ||
"@types/js-yaml": "4.0.5", | ||
"c8": "7.12.0", | ||
"tsup": "6.5.0", | ||
"typescript": "4.9.4", | ||
"vite": "4.0.3" | ||
}, | ||
"scripts": { | ||
"dev": "tsup --watch src", | ||
"example:dev": "pnpm -C example run dev", | ||
"example:build": "pnpm run build && pnpm -C example run build", | ||
"build": "tsup" | ||
"@types/js-yaml": "4.0.9", | ||
"c8": "8.0.1", | ||
"tsup": "8.0.1", | ||
"typescript": "5.3.3", | ||
"vite": "5.0.10" | ||
} | ||
} | ||
} |
@@ -32,2 +32,12 @@ [](https://github.com/Modyfi/vite-plugin-yaml/actions/workflows/pipeline.yml) | ||
Then you can simply import yaml files like you would any other file: | ||
```ts | ||
import YamlContent from './your.yaml'; | ||
console.log(YamlContent.example); | ||
``` | ||
Do note that you may have to include the file type in your import. | ||
### ๐ฆ TypeScript support | ||
@@ -79,2 +89,8 @@ | ||
/** | ||
* A boolean to determine if JSON object should be serialized. | ||
* | ||
* @see https://www.npmjs.com/package/tosource for the motivation behind serialization of JSON. | ||
*/ | ||
raw?: boolean; | ||
/** | ||
* A function that will be called for error reporting. | ||
@@ -81,0 +97,0 @@ * |
Sorry, the diff of this file is not supported yet
8788
29.75%7
16.67%107
5.94%100
19.05%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated