Closed jtojnar closed 2 years ago
The default YAML transformer is designed to allow you to import YAML into JavaScript, so it converts it as such. You could override this behavior by adding the following to a .parcelrc
file in your project:
{
"extends": "@parcel/config-default",
"transformers": {
"*.yaml": ["@parcel/transformer-raw"]
}
}
That still does not make sense to me in <link>
elements though. Especially when the resulting file is empty โ that would not be useful in JavaScript either.
For now, I managed to work around this by actually using the YAML from JS:
import config from ยด./config.yaml';
window.CMS_CONFIG = config;
import CMS from 'netlify-cms';
The JS was probably optimized away as it was unused. You are right that it doesn't make sense for <link>
but Parcel currently has no way to transform a file differently depending on which file type it was referenced in.
Did the above configuration in .parcelrc
not work for you?
Yeah, that works. Though, obviously, it will not work if I later decide to also load a YAML file from JavaScript.
You can use named pipelines to solve that issue. https://parceljs.org/features/plugins/#named-pipelines
๐ bug report
netlify-cms supports specifying path to its configuration using
<link href="path/to/config.yaml" type="text/yaml" rel="cms-config-url">
tag. However, when I add that to the HTML entry point, the YAML is turned into an empty (except for a comment) JavaScript file in the dist directory.๐ Configuration (.babelrc, package.json, cli command)
Building with
npx parcel build admin/index.html --dist-dir public/admin/ --public-url .
No special configuration, see the minimal example.
๐ค Expected Behavior
The config file should be copied to the dist directory as is (at most minified).
๐ฏ Current Behavior
๐ป Code Sample
https://github.com/jtojnar/repro/tree/738c2d442b504378b145edde2fdc52c8b2e217a0/parcel-netlify-cms
๐ Your Environment