2016-09-21 06:27:11 -08:00
|
|
|
const path = require('path');
|
2019-09-29 20:34:30 -08:00
|
|
|
const exec = require('child_process').exec;
|
2016-09-21 06:27:11 -08:00
|
|
|
|
2016-06-30 22:01:04 -08:00
|
|
|
const webpack = require('webpack');
|
2016-07-28 01:28:04 -08:00
|
|
|
const Copy = require('copy-webpack-plugin');
|
2019-09-08 10:41:06 -08:00
|
|
|
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
2016-06-30 22:01:04 -08:00
|
|
|
|
|
|
|
|
const nodeEnv = process.env.NODE_ENV || 'development';
|
|
|
|
|
const isProd = nodeEnv === 'production';
|
|
|
|
|
|
2018-01-09 06:05:19 -09:00
|
|
|
module.exports = [
|
2019-09-29 20:34:30 -08:00
|
|
|
{
|
|
|
|
|
mode: 'none',
|
|
|
|
|
name: 'hyper-app',
|
|
|
|
|
resolve: {
|
|
|
|
|
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json']
|
|
|
|
|
},
|
|
|
|
|
entry: './app/index.js',
|
|
|
|
|
output: {
|
|
|
|
|
path: path.join(__dirname, 'compiled_app'),
|
|
|
|
|
filename: 'ignore_this.js'
|
|
|
|
|
},
|
|
|
|
|
module: {
|
|
|
|
|
rules: [
|
|
|
|
|
{
|
|
|
|
|
test: /\.(js|jsx|ts|tsx)$/,
|
|
|
|
|
exclude: /node_modules/,
|
|
|
|
|
loader: 'null-loader'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
plugins: [
|
|
|
|
|
new Copy([
|
|
|
|
|
{
|
|
|
|
|
from: './app/*.html',
|
|
|
|
|
exclude: /node_modules/,
|
|
|
|
|
to: '.',
|
|
|
|
|
flatten: true
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
from: './app/*.json',
|
|
|
|
|
exclude: /node_modules/,
|
|
|
|
|
to: '.',
|
|
|
|
|
flatten: true
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
from: './app/keymaps/*.json',
|
|
|
|
|
exclude: /node_modules/,
|
|
|
|
|
to: './keymaps',
|
|
|
|
|
flatten: true
|
|
|
|
|
}
|
|
|
|
|
// {
|
|
|
|
|
// from: './app/node_modules', // gives really long output in webpack, used cp instead
|
|
|
|
|
// to: './node_modules'
|
|
|
|
|
// }
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
apply: compiler => {
|
|
|
|
|
compiler.hooks.afterEmit.tap('AfterEmitPlugin', () => {
|
|
|
|
|
exec('cp -r ./app/node_modules ./compiled_app && tsc', (err, stdout, stderr) => {
|
|
|
|
|
if (stdout) process.stdout.write(stdout);
|
|
|
|
|
if (stderr) process.stderr.write(stderr);
|
|
|
|
|
process.stdout.write('\nCompiled\n\n');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new ForkTsCheckerWebpackPlugin()
|
|
|
|
|
],
|
|
|
|
|
target: 'electron-main'
|
|
|
|
|
},
|
|
|
|
|
|
2018-01-09 06:05:19 -09:00
|
|
|
{
|
2019-09-04 22:49:56 -08:00
|
|
|
mode: 'none',
|
2018-01-09 06:05:19 -09:00
|
|
|
name: 'hyper',
|
|
|
|
|
resolve: {
|
2019-09-08 10:41:06 -08:00
|
|
|
extensions: ['.js', '.jsx', '.ts', '.tsx']
|
2018-01-09 06:05:19 -09:00
|
|
|
},
|
|
|
|
|
devtool: isProd ? 'hidden-source-map' : 'cheap-module-source-map',
|
|
|
|
|
entry: './lib/index.js',
|
|
|
|
|
output: {
|
2019-09-29 20:34:30 -08:00
|
|
|
path: path.join(__dirname, 'compiled_app', 'renderer'),
|
2018-01-09 06:05:19 -09:00
|
|
|
filename: 'bundle.js'
|
|
|
|
|
},
|
|
|
|
|
module: {
|
|
|
|
|
rules: [
|
|
|
|
|
{
|
2019-09-08 10:41:06 -08:00
|
|
|
test: /\.(js|jsx|ts|tsx)$/,
|
2018-01-09 06:05:19 -09:00
|
|
|
exclude: /node_modules/,
|
|
|
|
|
loader: 'babel-loader'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.json/,
|
|
|
|
|
loader: 'json-loader'
|
|
|
|
|
},
|
|
|
|
|
// for xterm.js
|
|
|
|
|
{
|
|
|
|
|
test: /\.css$/,
|
|
|
|
|
loader: 'style-loader!css-loader'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
plugins: [
|
|
|
|
|
new webpack.IgnorePlugin(/.*\.js.map$/i),
|
2017-09-25 05:26:04 -08:00
|
|
|
|
2018-01-09 06:05:19 -09:00
|
|
|
new webpack.DefinePlugin({
|
|
|
|
|
'process.env': {
|
|
|
|
|
NODE_ENV: JSON.stringify(nodeEnv)
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
new Copy([
|
|
|
|
|
{
|
|
|
|
|
from: './assets',
|
|
|
|
|
to: './assets'
|
|
|
|
|
}
|
2019-09-08 10:41:06 -08:00
|
|
|
]),
|
2019-09-29 20:34:30 -08:00
|
|
|
new ForkTsCheckerWebpackPlugin({
|
|
|
|
|
tsconfig: './lib/tsconfig.json'
|
|
|
|
|
})
|
2018-01-09 06:05:19 -09:00
|
|
|
],
|
2019-09-04 22:49:56 -08:00
|
|
|
target: 'electron-renderer'
|
2018-01-09 06:05:19 -09:00
|
|
|
},
|
|
|
|
|
{
|
2019-09-04 22:49:56 -08:00
|
|
|
mode: 'none',
|
2018-01-09 06:05:19 -09:00
|
|
|
name: 'hyper-cli',
|
|
|
|
|
resolve: {
|
|
|
|
|
extensions: ['.js', '.jsx', '.json']
|
|
|
|
|
},
|
|
|
|
|
devtool: isProd ? 'none' : 'cheap-module-source-map',
|
|
|
|
|
entry: './cli/index.js',
|
|
|
|
|
output: {
|
|
|
|
|
path: path.join(__dirname, 'bin'),
|
|
|
|
|
filename: 'cli.js'
|
|
|
|
|
},
|
|
|
|
|
module: {
|
|
|
|
|
rules: [
|
|
|
|
|
{
|
|
|
|
|
test: /\.(js|jsx)$/,
|
|
|
|
|
exclude: /node_modules/,
|
|
|
|
|
loader: 'babel-loader'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /index.js/,
|
|
|
|
|
loader: 'shebang-loader',
|
|
|
|
|
include: [/node_modules\/rc/]
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
plugins: [
|
|
|
|
|
// spawn-sync is required by execa if node <= 0.10
|
|
|
|
|
new webpack.IgnorePlugin(/(.*\.js.map|spawn-sync)$/i),
|
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
|
'process.env.NODE_ENV': JSON.stringify(nodeEnv)
|
|
|
|
|
})
|
|
|
|
|
],
|
|
|
|
|
target: 'node'
|
|
|
|
|
}
|
|
|
|
|
];
|