Skip to content

Snowpack plugin to load file with unicode text directly into a javascript string

Notifications You must be signed in to change notification settings

wires/snowpack-plugin-unicode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

snowpack-plugin-unicode

With this snowpack plugin you can load files with unicode text directly into a javascript string.

Usage

This converts the file contents into an array of numberic UTF-16 character codes and then uses String.fromCharCode in the browser to load this.

import stringContents from "./Unicode.md"

Installation

npm install -D snowpack-plugin-unicode

And to your snowpack.config.json add

{
    "plugins": [
        ["snowpack-plugin-unicode", {
            "inputExtensions": [".md", ".csv.txt" ],
            "inputEncoding": "utf-8"
        }]
    ]
}

There is one optional configuration setting: inputExtensions. With this you specify which extensions we should load. Default is ['.md', '.txt'].

The source file encoding defaults to utf-8, but can be changed with the configuration setting inputEncoding (not tested extensively).

About

Snowpack plugin to load file with unicode text directly into a javascript string

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published