Skip to content

Commit

Permalink
add package script
Browse files Browse the repository at this point in the history
  • Loading branch information
chentsulin committed May 22, 2015
1 parent 3d9e23c commit 3aeed0f
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
</head>
<body>
<div id="react-root"></div>
<script src="bundle.js"></script>
<script src="../dist/bundle.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion app/routes/router.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import routes from './routes.jsx'
import routes from './routes'
import Router from 'react-router'


Expand Down
File renamed without changes.
14 changes: 7 additions & 7 deletions make-webpack-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ module.exports = function(opts) {

var modulesDirectories = [ 'node_modules' ]

var extensions = ['', '.web.js', '.js', '.jsx'];
var extensions = ['', '.js', '.jsx'];

var root = path.join(__dirname, 'app')

var publicPath = opts.devServer
? 'http://localhost:2992/_assets/'
: '/_assets/'
? 'http://localhost:2992/dist/'
: '/dist/'


var output = {
path: __dirname + '/_assets/',
path: __dirname + '/dist/',
filename: 'bundle.js',
publicPath: 'http://localhost:2992/',
contentBase: __dirname + '/public/'
Expand All @@ -84,7 +84,7 @@ module.exports = function(opts) {
]

if (opts.prerender) {
plugins.push(new StatsPlugin(path.join(__dirname, 'build', 'stats.prerender.json'), {
plugins.push(new StatsPlugin(path.join(__dirname, 'dist', 'stats.prerender.json'), {
chunkModules: true,
exclude: excludeFromStats
}));
Expand All @@ -98,7 +98,7 @@ module.exports = function(opts) {
);
plugins.push(new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }));
} else {
plugins.push(new StatsPlugin(path.join(__dirname, 'build', 'stats.json'), {
plugins.push(new StatsPlugin(path.join(__dirname, 'dist', 'stats.json'), {
chunkModules: true,
exclude: excludeFromStats
}));
Expand Down Expand Up @@ -146,7 +146,7 @@ module.exports = function(opts) {
plugins.push(
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
NODE_ENV: "'production'"
}
}),
new webpack.NoErrorsPlugin()
Expand Down
45 changes: 45 additions & 0 deletions package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
var packager = require('electron-packager')
var assign = require('object-assign')

var DEFAULT_OPTS = {
version: '0.26.1',
dir: './',
name: 'ElectronReact'
}

var MacOS_OPTS = assign({}, DEFAULT_OPTS, {
platform: 'darwin',
arch: 'x64',
out: 'release/darwin',
})

var Linux_OPTS = assign({}, DEFAULT_OPTS, {
platform: 'linux',
arch: 'x64',
out: 'release/linux',
})

var Windows_OPTS = assign({}, DEFAULT_OPTS, {
platform: 'win32',
arch: 'x64',
out: 'release/win32',
})


pack(MacOS_OPTS, thenPack(Linux_OPTS, thenPack(Windows_OPTS, log)))


function pack(opts, cb) {
packager(opts, cb)
}

function thenPack(opts, cb) {
return function() {
packager(opts, cb)
}
}

function log(err, filepath) {
if (err) return console.error(err)
console.log('finished!')
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"hot-dev-server": "webpack-dev-server --config webpack-hot-dev-server.config.js --hot --progress --colors --port 2992 --inline",
"build": "webpack --config webpack-production.config.js --progress --profile --colors",
"start-hot": "HOT=1 /Applications/Electron.app/Contents/MacOS/Electron .",
"start": "/Applications/Electron.app/Contents/MacOS/Electron ."
"start": "/Applications/Electron.app/Contents/MacOS/Electron .",
"package": "node package.js"
},
"repository": {
"type": "git",
Expand All @@ -30,6 +31,7 @@
"babel-loader": "^5.1.2",
"chai": "^2.3.0",
"css-loader": "^0.12.1",
"electron-packager": "^4.1.0",
"electron-prebuilt": "^0.26.0",
"extract-text-webpack-plugin": "^0.8.0",
"file-loader": "^0.8.1",
Expand Down

0 comments on commit 3aeed0f

Please sign in to comment.