Skip to content
This repository has been archived by the owner on Jun 13, 2018. It is now read-only.

YIIZ/codegen-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

codegen-loader

Code generate

Usage

app.js

import { buildInfo } from '!!codegen-loader!./macro'
console.log(buildInfo) // 1.0.0#184a33

macro.js

const { version } = require('./package.json')
const hash = require('child_process').execSync('git rev-parse HEAD')
const info = `${version}#${hash.slice(0, 6)}`

module.exports = `
export const buildInfo = ${JSON.stringify(info)}
`