feat(electron): complete electron integration

* chore(package): update webpack to beta.22

Lastest version before breaking changes.

* feat(electron): Complete Electron integration.

New task to build targeting Electron:

    "build:electron": Alias for build:electron.full
    "prebuild:electron.full": "npm run clean:electron",
    "build:electron.full": "npm run build:electron.renderer && npm run build:electron.main",
    "postbuild:electron.full": "npm run electron:start",

    "build:electron.renderer": Webpack aplication with production properties and targeting electron-renderer
    "build:electron.main": Webpack main Electron with production properties and targeting electron

    "electron:start": "electron build"
This commit is contained in:
Michael De Abreu 2016-10-12 08:59:51 -04:00 committed by Tibing
parent fd09e652c8
commit c6a9d67a83
12 changed files with 208 additions and 32 deletions

View file

@ -0,0 +1,38 @@
const helpers = require('./../helpers');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
entry: {
'main': './src/desktop.ts'
},
target: 'electron',
node: {
__dirname: false
},
output: {
path: helpers.root('build'),
filename: '[name].js'
},
resolve: {
extensions: ['', '.ts', '.js', '.json']
},
module: {
loaders: [
{
test: /\.ts$/,
loader: 'awesome-typescript-loader'
}
]
},
plugins: [
new CopyWebpackPlugin([{
from: 'src/package.json'
}])
]
}

View file

@ -0,0 +1,21 @@
const webpack = require('webpack');
const webpackMerge = require('webpack-merge');
const commonConfig = require('./webpack.electron.common.js');
const WebpackShellPlugin = require('./webpack-shell-plugin');
const ENV = process.env.NODE_ENV = process.env.ENV = 'development';
module.exports = webpackMerge(commonConfig, {
plugins: [
new WebpackShellPlugin({
//TODO: Kill electron process before build, to start the new one fresh.
onBuildStart: [''],
onBuildEnd: ['electron dist']
}),
new webpack.DefinePlugin({
'process.env': {
'ENV': JSON.stringify(ENV)
}
})
]
});

View file

@ -0,0 +1,26 @@
const webpack = require('webpack');
const webpackMerge = require('webpack-merge');
const commonConfig = require('./webpack.electron.common.js');
const ENV = process.env.NODE_ENV = process.env.ENV = 'production';
module.exports = webpackMerge(commonConfig, {
plugins: [
// new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
beautify: false,
mangle: {
screw_ie8: true
},
compress: {
screw_ie8: true
},
comments: false
}),
new webpack.DefinePlugin({
'process.env': {
'ENV': JSON.stringify(ENV)
}
})
]
});

View file

@ -0,0 +1,67 @@
const helpers = require('./../helpers');
const webpack = require('webpack');
const METADATA = {
baseUrl: './',
ENV: 'renderer',
};
/*
* Webpack configuration
*
* See: http://webpack.github.io/docs/configuration.html#cli
*/
module.exports = function (env) {
METADATA.ENV = env
? env
: METADATA.ENV
return {
/*
* Static metadata for index.html
*
* See: (custom attribute)
*/
metadata: METADATA,
/**
* The plataform target where the aplication is going to run in.
* It support target electron-renderer, but is not documented.
*
* See: https://webpack.github.io/docs/configuration.html#target
*/
target: 'electron-renderer',
/**
* Options affecting the output of the compilation.
*
* See: http://webpack.github.io/docs/configuration.html#output
*/
output: {
/**
* The output directory as absolute path (required).
*
* See: http://webpack.github.io/docs/configuration.html#output-path
*/
path: helpers.root('build'),
},
/*
* Include polyfills or mocks for various node stuff
* Description: Node configuration
*
* See: https://webpack.github.io/docs/configuration.html#node
*/
node: {
global: 'window',
crypto: 'empty',
process: true,
module: false,
clearImmediate: false,
setImmediate: false
}
};
};

View file

@ -0,0 +1,6 @@
const devConfig = require('./../webpack.dev');
const commonConfig = require('./webpack.renderer.common');
const webpackMerge = require('webpack-merge');
module.exports = webpackMerge(devConfig(), commonConfig(), {
});

View file

@ -0,0 +1,6 @@
const prodConfig = require('./../webpack.prod');
const commonConfig = require('./webpack.renderer.common');
const webpackMerge = require('webpack-merge');
module.exports = webpackMerge(prodConfig(), commonConfig(), {
});