GithubHelp home page GithubHelp logo

deno_pkger's Introduction

Build Status

Deno General Resources Packager

It is very painful for loading static resources

The library is to convert static resource files into ts files

You can easily bundle static resources into your code

Because it needs to be loaded into memory, it is not recommended to bundle large files

Usage

  1. Install the command line tool
$ deno install -A --unstable -f https://raw.githubusercontent.com/axetroy/deno_pkger/master/pkger.ts
  1. Generate file from static resource
$ tree ./static
./example/
├── index.html
└── views
    ├── home.html
$ pkger --include=./static --out=./dist
$ tree ./dist
dist/
├── index.html.bundle.ts
└── views
    └── home.html.bundle.ts
  1. Load the static file
import fs from 'https://denopkg.com/axetroy/deno_pkger/mod.ts'
import './dist/index.html.bundle.ts'

const stat = await fs.stat('/index.html')
console.log(stat)
// {
//   isFile: true,
//   isDirectory: false,
//   isSymlink: false,
//   size: 218,
//   mtime: new Date('2020-05-31T03:00:19.096Z'),
//   atime: new Date('2020-05-31T03:00:20.150Z'),
//   birthtime: new Date('2020-05-31T03:00:06.181Z'),
//   dev: 16777220,
//   ino: 4400719062,
//   mode: 33188,
//   nlink: 1,
//   uid: 501,
//   gid: 20,
//   rdev: 0,
//   blksize: 4096,
//   blocks: 8
// }

const bytes = await fs.readFile('/index.html')

console.log(bytes)

const reader = await fs.open('/index.html')

reader.write(new Uint8Array([97, 98, 99, 100]))

deno_pkger's People

Contributors

axetroy avatar

Stargazers

masx200 avatar  avatar codenameCookie avatar Eduardo Rabelo avatar  avatar EnokMan avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

marktiedemann

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.