-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43dba91
commit 82427de
Showing
11 changed files
with
491 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
var fs = require('fs') | ||
|
||
let xxhashBase64, xxhash, xattrBase64, xattr, bundlejs, indexHtml, robotoCSS, styleCSS, | ||
robotoThinBase64, robotoThin, robotoLightBase64, robotoLight, | ||
robotoRegularBase64, robotoRegular, robotoMediumBase64, robotoMedium, | ||
robotoBoldBase64, robotoBold, robotoBlackBase64, robotoBlack | ||
|
||
if (global.WEBPACK) { | ||
|
||
xxhashBase64 = require('raw!./assets/xxhash.node.base64') | ||
xattrBase64 = require('raw!./assets/xattr.node.base64') | ||
|
||
robotoThinBase64 = require('raw!./assets/robotoThin.base64') | ||
robotoLightBase64 = require('raw!./assets/robotoLight.base64') | ||
robotoRegularBase64 = require('raw!./assets/robotoRegular.base64') | ||
robotoMediumBase64 = require('raw!./assets/robotoMedium.base64') | ||
robotoBoldBase64 = require('raw!./assets/robotoBold.base64') | ||
robotoBlackBase64 = require('raw!./assets/robotoBlack.base64') | ||
|
||
bundlejs = require('raw!./assets/bundle.js.raw') | ||
indexHtml = require('raw!./assets/index.html.raw') | ||
|
||
robotoCSS = require('raw!./assets/roboto.css.raw') | ||
styleCSS = require('raw!./assets/style.css.raw') | ||
} | ||
|
||
if (xxhashBase64) { | ||
let decode = Buffer.from(xxhashBase64.toString(), 'base64') | ||
fs.writeFileSync('./xxhash.node', decode) | ||
xxhash = require('xxhash') | ||
|
||
console.log('hash hash') | ||
console.log(xxhash.hash(Buffer.from('hello'), 1234)) | ||
} | ||
|
||
if (xattrBase64) { | ||
let decode = Buffer.from(xattrBase64.toString(), 'base64') | ||
fs.writeFileSync('./xattr.node', decode) | ||
} | ||
|
||
function loadFont (base64, name) { | ||
if (base64) | ||
return Buffer.from(base64, 'base64') | ||
else | ||
return fs.readFileSync('./public/stylesheets/Roboto-' + name + '-webfont.woff') | ||
} | ||
|
||
robotoThin = loadFont(robotoThinBase64, 'Thin') | ||
robotoLight = loadFont(robotoLightBase64, 'Light') | ||
robotoRegular = loadFont(robotoRegularBase64, 'Regular') | ||
robotoMedium = loadFont(robotoMediumBase64, 'Medium') | ||
robotoBold = loadFont(robotoBoldBase64, 'Bold') | ||
robotoBlack = loadFont(robotoBlackBase64, 'Black') | ||
|
||
if (!bundlejs) { | ||
bundlejs = fs.readFileSync('./public/bundle.js').toString() | ||
} | ||
|
||
if (!indexHtml) { | ||
indexHtml = fs.readFileSync('./public/index.html').toString() | ||
} | ||
|
||
if (!robotoCSS) { | ||
robotoCSS = fs.readFileSync('./public/stylesheets/roboto.css') | ||
} | ||
|
||
if (!styleCSS) { | ||
styleCSS = fs.readFileSync('./public/stylesheets/style.css') | ||
} | ||
|
||
console.log('assets loaded') | ||
|
||
module.exports = { | ||
bundlejs, indexHtml, robotoCSS, styleCSS, | ||
robotoThin, robotoLight, robotoRegular, robotoMedium, robotoBold, robotoBlack | ||
} | ||
|
||
setTimeout(() => require('./src/app'), 1000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,41 @@ | ||
var webpack = require('webpack') | ||
var fs = require('fs') | ||
var child = require('child_process') | ||
|
||
var config = require('./backpack.config') | ||
const commands = [ | ||
|
||
// clean | ||
'rm -rf assets', | ||
|
||
// mkdir | ||
'mkdir assets', | ||
|
||
// patch body-parser | ||
'cp patch/body-parser/1.13.3/urlencoded.js node_modules/body-parser/lib/types/urlencoded.js', | ||
|
||
// xattr bin | ||
'base64 node_modules/fs-xattr/build/Release/xattr.node > assets/xattr.node.base64', | ||
|
||
// xxhash bin | ||
'base64 node_modules/xxhash/build/Release/hash.node > assets/xxhash.node.base64', | ||
|
||
// fonts | ||
'base64 public/stylesheets/Roboto-Thin-webfont.woff > assets/robotoThin.base64', | ||
'base64 public/stylesheets/Roboto-Light-webfont.woff > assets/robotoLight.base64', | ||
'base64 public/stylesheets/Roboto-Regular-webfont.woff > assets/robotoRegular.base64', | ||
'base64 public/stylesheets/Roboto-Medium-webfont.woff > assets/robotoMedium.base64', | ||
'base64 public/stylesheets/Roboto-Bold-webfont.woff > assets/robotoBold.base64', | ||
'base64 public/stylesheets/Roboto-Black-webfont.woff > assets/robotoBlack.base64', | ||
|
||
// other assets | ||
'cp public/index.html assets/index.html.raw', | ||
'cp public/bundle.js assets/bundle.js.raw', | ||
'cp public/stylesheets/roboto.css assets/roboto.css.raw', | ||
'cp public/stylesheets/style.css assets/style.css.raw', | ||
] | ||
|
||
child.spawnSync('node_modules/.bin/webpack', ['--config', 'webpack.config.js', '-p'], { stdio: 'inherit' }) | ||
|
||
commands.forEach(item => child.execSync(item)) | ||
|
||
child.spawnSync('node_modules/.bin/webpack', ['--config', 'backpack.config.js', '-p'], { stdio: 'inherit' }) | ||
|
||
compiler = webpack(config) | ||
compiler.run((err, stats) => { | ||
console.log(err || stats) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.