Skip to content

Commit

Permalink
[renderer] get card from game server
Browse files Browse the repository at this point in the history
  • Loading branch information
toyobayashi committed Jul 24, 2018
1 parent 6672a5e commit 96cba22
Show file tree
Hide file tree
Showing 18 changed files with 1,242 additions and 1,125 deletions.
2 changes: 1 addition & 1 deletion app/.npmrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build_from_source = true
runtime = "electron"
target = "2.0.2"
target = "2.0.5"
dist_url = "https://atom.io/download/electron"
1,926 changes: 949 additions & 977 deletions app/package-lock.json

Large diffs are not rendered by default.

31 changes: 13 additions & 18 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
{
"name": "mishiro",
"version": "1.3.5",
"version": "1.3.6",
"description": "mishiro",
"main": "./public/mishiro.main.js",
"scripts": {
"clr": "ts-node -P ./script/tsconfig.json ./script/pre-install.ts",
"install32": "npm run clr&&npm install --target_arch=ia32 --arch=ia32",
"install64": "npm run clr&&npm install --target_arch=x64 --arch=x64",
"install": "ts-node -P ./script/tsconfig.json ./script/after-npm-install.ts",
"start": "electron . --enable-logging",
"dll": "ts-node -P ./script/tsconfig.json ./script/webpack.ts dll",
"dev": "ts-node -P ./script/tsconfig.json ./script/webpack.ts webpack",
"prod": "cross-env NODE_ENV=production ts-node -P ./script/tsconfig.json ./script/webpack.ts webpack",
"pkg32": "npm run install32&&cross-env NODE_ENV=production ts-node -P ./script/tsconfig.json ./script/packager.ts ia32",
"pkg64": "npm run install64&&cross-env NODE_ENV=production ts-node -P ./script/tsconfig.json ./script/packager.ts x64",
"pkg32": "cross-env NODE_ENV=production ts-node -P ./script/tsconfig.json ./script/packager.ts ia32",
"pkg64": "cross-env NODE_ENV=production ts-node -P ./script/tsconfig.json ./script/packager.ts x64",
"count": "ts-node -P ./script/tsconfig.json ./script/source-count.ts",
"dlc": "ts-node -P ./script/tsconfig.json ./script/release-download-count.ts"
},
Expand Down Expand Up @@ -43,32 +38,32 @@
"@types/sqlite3": "^3.1.3",
"@types/uglifyjs-webpack-plugin": "^1.1.0",
"@types/webpack": "^4.4.3",
"@types/webpack-node-externals": "^1.6.3",
"cross-env": "^5.1.6",
"css-loader": "^0.28.11",
"electron": "2.0.2",
"electron": "2.0.5",
"electron-packager": "^12.0.2",
"fs-extra": "^6.0.1",
"mini-css-extract-plugin": "^0.4.0",
"mishiro-core": "^1.0.1",
"native-addon-loader": "^1.1.0",
"optimize-css-assets-webpack-plugin": "^4.0.0",
"sqlite3": "^4.0.0",
"ts-loader": "^4.2.0",
"ts-node": "^5.0.1",
"tslint": "^5.9.1",
"tslint-config-standard": "^7.0.0",
"typescript": "^2.9.2",
"uglifyjs-webpack-plugin": "^1.2.4",
"vue": "^2.5.16",
"vue-i18n": "^7.4.2",
"vue-loader": "^15.0.9",
"vue-property-decorator": "^7.0.0",
"vue-template-compiler": "^2.5.16",
"webpack": "^4.12.2",
"webpack": "^4.16.2",
"webpack-node-externals": "^1.7.2",
"zauz": "^1.0.0"
},
"dependencies": {
"fs-extra": "^7.0.0",
"marked": "^0.3.14",
"vue": "^2.5.16",
"vue-class-component": "^6.2.0",
"vue-i18n": "^7.4.2",
"vue-property-decorator": "^6.0.0"
"mishiro-core": "^1.1.0",
"sqlite3": "^4.0.2"
}
}
5 changes: 3 additions & 2 deletions app/script/packager.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ import pkg from '../package.json'
if (process.argv.slice(2)[0] !== 'ia32' && process.argv.slice(2)[0] !== 'x64') {
throw new Error('ARCH requrie "ia32" or "x64"')
}
const arch = process.argv.slice(2)[0] as packageManager.arch
export const arch = process.argv.slice(2)[0] as packageManager.arch

export const productionPackage = {
name: pkg.name,
version: pkg.version,
main: pkg.main,
author: pkg.author,
repository: pkg.repository,
license: pkg.license
license: pkg.license,
dependencies: pkg.dependencies
}

export const packagerOptions: packageManager.Options = {
Expand Down
25 changes: 18 additions & 7 deletions app/script/packager.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import packager from 'electron-packager'
import path from 'path'
import fs from 'fs-extra'
import { exec } from 'child_process'
import pkg from '../package.json'
import { prod } from './webpack'
import { ilog, wlog, elog } from './rainbow'
import { zip } from 'zauz'
import { productionPackage, packagerOptions } from './packager.config'
// import { zip } from 'zauz'
import { productionPackage, packagerOptions, arch } from './packager.config'

function _exec (cmd: string, opt: any) {
return new Promise((resolve, reject) => {
exec(cmd, opt, (err) => {
if (err) return reject(err)
resolve()
})
})
}

function bundleProductionCode () {
ilog(`[${new Date().toLocaleString()}] Bundle production code...`)
Expand Down Expand Up @@ -41,10 +51,10 @@ async function rename (appPath: string) {
return newPath
}

function zipApp (p: string) {
/* function zipApp (p: string) {
ilog(`[${new Date().toLocaleString()}] Zip ${p}`)
return zip(p, p + '.zip')
}
} */

async function main () {
const start = new Date().getTime()
Expand All @@ -53,10 +63,11 @@ async function main () {
const [appPath] = await packageApp()
const root = process.platform === 'darwin' ? path.join(appPath, 'Electron.app/Contents/Resources/app') : path.join(appPath, 'resources/app')
await writePackageJson(root)
await _exec(`npm install --production --arch=${arch} --target_arch=${arch} --build-from-source --runtime=electron --target=2.0.5 --dist-url=https://atom.io/download/electron`, { cwd: root })
await copyExtra(root)
const newPath = await rename(appPath)
const size = await zipApp(newPath)
ilog(`[${new Date().toLocaleString()}] Size: ${size} Bytes`)
await rename(appPath)
// const size = await zipApp(newPath)
// ilog(`[${new Date().toLocaleString()}] Size: ${size} Bytes`)
return (new Date().getTime() - start) / 1000
}

Expand Down
135 changes: 74 additions & 61 deletions app/script/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import OptimizeCSSAssetsPlugin from 'optimize-css-assets-webpack-plugin'
import UglifyJSPlugin from 'uglifyjs-webpack-plugin'
import { VueLoaderPlugin } from 'vue-loader'
import path from 'path'
import fs from 'fs-extra'
import pkg from '../package.json'
// import fs from 'fs-extra'
import webpackNodeExternals from 'webpack-node-externals'
// import pkg from '../package.json'

export const mode = process.env.NODE_ENV === 'production' ? 'production' : 'development'
const uglify = new UglifyJSPlugin({
Expand All @@ -21,7 +22,7 @@ const uglify = new UglifyJSPlugin({
}
})

export const dll: webpack.Configuration = {
/* export const dll: webpack.Configuration = {
mode,
target: 'electron-renderer',
entry: {
Expand All @@ -46,7 +47,7 @@ export const dll: webpack.Configuration = {
optimization: {
minimizer: [uglify]
}
}
} */

export const main: webpack.Configuration = {
mode,
Expand All @@ -73,6 +74,7 @@ export const main: webpack.Configuration = {
}
}]
},
externals: [webpackNodeExternals()],
resolve: {
extensions: ['.ts', '.js', '.json', '.node']
},
Expand All @@ -83,64 +85,75 @@ export const main: webpack.Configuration = {

export const manifest: any = path.join(__dirname, 'manifest.json')

export function renderer (manifestPath: string): webpack.Configuration {
const manifestJson = fs.readJsonSync(manifestPath)
console.log('Global variable name: ' + manifestJson.name)
return {
mode,
target: 'electron-renderer',
entry: {
'mishiro.renderer': path.join(__dirname, '../src/ts/renderer.ts'),
'mishiro.live': path.join(__dirname, '../src/ts/renderer-game.ts')
},
output: {
path: path.join(__dirname, '../public'),
filename: '[name].js'
},
node: {
__dirname: false,
__filename: false
},
module: {
rules: [{
test: /\.vue$/,
exclude: /node_modules/,
loader: 'vue-loader'
}, {
test: /\.css$/,
exclude: /node_modules/,
use: [
MiniCssExtractPlugin.loader,
{ loader: 'css-loader', options: { url: false } }
]
}, {
test: /\.ts$/,
exclude: /node_modules/,
loader: 'ts-loader',
options: {
appendTsSuffixTo: [/\.vue$/]
}
}]
},
resolve: {
extensions: ['.ts', '.js', '.vue', '.css']
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css'
}),
new webpack.DllReferencePlugin({
manifest: manifestJson,
context: __dirname
}),
new VueLoaderPlugin()
],
optimization: {
minimizer: [
uglify,
new OptimizeCSSAssetsPlugin({})
export const renderer: webpack.Configuration = {
// const manifestJson = fs.readJsonSync(manifestPath)
// console.log('Global variable name: ' + manifestJson.name)
mode,
target: 'electron-renderer',
entry: {
'mishiro.renderer': path.join(__dirname, '../src/ts/renderer.ts'),
'mishiro.live': path.join(__dirname, '../src/ts/renderer-game.ts')
},
output: {
path: path.join(__dirname, '../public'),
filename: '[name].js'
},
node: {
__dirname: false,
__filename: false
},
module: {
rules: [{
test: /\.vue$/,
exclude: /node_modules/,
loader: 'vue-loader'
}, {
test: /\.css$/,
exclude: /node_modules/,
use: [
MiniCssExtractPlugin.loader,
{ loader: 'css-loader', options: { url: false } }
]
}, {
test: /\.ts$/,
exclude: /node_modules/,
loader: 'ts-loader',
options: {
appendTsSuffixTo: [/\.vue$/]
}
}]
},
resolve: {
extensions: ['.ts', '.js', '.vue', '.css']
},
externals: [webpackNodeExternals({
whitelist: [/vue/]
})],
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css'
}),
/* new webpack.DllReferencePlugin({
manifest: manifestJson,
context: __dirname
}), */
new VueLoaderPlugin()
],
optimization: {
minimizer: [
uglify,
new OptimizeCSSAssetsPlugin({})
],
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: 'dll',
chunks: 'all'
}
}
}
}

}
Loading

0 comments on commit 96cba22

Please sign in to comment.