Skip to content

Commit

Permalink
Add main proc build to package.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jhen0409 committed Apr 9, 2016
1 parent 7f4cbe2 commit 58a66aa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
18 changes: 12 additions & 6 deletions package.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
const os = require('os');
const webpack = require('webpack');
const cfg = require('./webpack.config.production.js');
const electronCfg = require('./webpack.config.electron.js');
const packager = require('electron-packager');
const del = require('del');
const exec = require('child_process').exec;
Expand Down Expand Up @@ -52,12 +53,19 @@ if (version) {
});
}

function build(cfg) {
return new Promise((resolve, reject) => {
webpack(cfg, (err, stats) => {
if (err) return reject(err);
resolve(stats);
});
});
}

function startPack() {
console.log('start pack...');
webpack(cfg, (err, stats) => {
if (err) return console.error(err);
del('release')
build(electronCfg).then(() => build(cfg))
.then(() => del('release'))
.then(paths => {
if (shouldBuildAll) {
// build for all platforms
Expand All @@ -73,11 +81,9 @@ function startPack() {
// build for current platform only
pack(os.platform(), os.arch(), log(os.platform(), os.arch()));
}
})
.catch(err => {
}).catch(err => {
console.error(err);
});
});
}

function pack(plat, arch, cb) {
Expand Down
10 changes: 6 additions & 4 deletions webpack.config.electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ const baseConfig = require('./webpack.config.base');
const config = Object.create(baseConfig);

config.devtool = 'source-map';
config.output.path = __dirname;
config.output.filename = './main.js';
config.output = {
path: __dirname,
filename: './main.js'
};
config.entry = './main.development';
config.plugins.push(
config.plugins = [
new webpack.BannerPlugin(
'require("source-map-support").install();',
{ raw: true, entryOnly: false }
Expand All @@ -20,7 +22,7 @@ config.plugins.push(
NODE_ENV: JSON.stringify('production')
}
})
);
];
config.target = 'electron';
config.node = {
__dirname: false,
Expand Down
8 changes: 4 additions & 4 deletions webpack.config.production.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ config.entry = './app/index';

config.output.publicPath = '../dist/';

config.module.loaders.push({
config.module.loaders = config.module.loaders.concat([{
test: /\.global\.css$/,
loader: ExtractTextPlugin.extract(
'style-loader',
Expand All @@ -27,9 +27,9 @@ config.module.loaders.push({
'style-loader',
'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]'
)
});
}]);

config.plugins.push(
config.plugins = config.plugins.concat([
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
__DEV__: false,
Expand All @@ -44,7 +44,7 @@ config.plugins.push(
}
}),
new ExtractTextPlugin('style.css', { allChunks: true })
);
]);

config.target = webpackTargetElectronRenderer(config);

Expand Down

0 comments on commit 58a66aa

Please sign in to comment.