2018-01-18 03:13:08 +01:00
|
|
|
const path = require('path');
|
2018-07-26 01:38:47 +02:00
|
|
|
const FilewatcherPlugin = require('filewatcher-webpack-plugin');
|
2017-12-04 20:45:18 +01:00
|
|
|
|
2018-01-18 03:13:08 +01:00
|
|
|
const ELECTRON_RENDERER_PROCESS_ROOT = path.resolve(__dirname, 'src/renderer/');
|
2017-12-04 20:45:18 +01:00
|
|
|
|
2018-07-26 03:55:42 +02:00
|
|
|
let PROCESS_ARGV = process.env.npm_config_argv;
|
|
|
|
if (PROCESS_ARGV) {
|
|
|
|
PROCESS_ARGV = JSON.parse(PROCESS_ARGV);
|
|
|
|
}
|
|
|
|
|
|
|
|
const isDev = PROCESS_ARGV && PROCESS_ARGV.original &&
|
|
|
|
(PROCESS_ARGV.original.indexOf('dev') !== -1);
|
|
|
|
|
2017-12-04 20:45:18 +01:00
|
|
|
module.exports = {
|
|
|
|
// This rule is temporarily necessary until https://github.com/electron-userland/electron-webpack/issues/60 is fixed.
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.jsx?$/,
|
2017-12-21 18:32:51 +01:00
|
|
|
loader: 'babel-loader',
|
2017-12-04 20:45:18 +01:00
|
|
|
options: {
|
2017-12-21 18:32:51 +01:00
|
|
|
presets: ['env', 'react', 'stage-2'],
|
2017-12-20 16:38:52 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2017-12-04 20:45:18 +01:00
|
|
|
},
|
|
|
|
// This allows imports to be made from the renderer process root (https://moduscreate.com/blog/es6-es2015-import-no-relative-path-webpack/).
|
|
|
|
resolve: {
|
2017-12-21 18:32:51 +01:00
|
|
|
modules: [ELECTRON_RENDERER_PROCESS_ROOT, 'node_modules', __dirname],
|
|
|
|
extensions: ['.js', '.jsx', '.scss'],
|
2017-12-20 16:38:52 +01:00
|
|
|
},
|
2018-07-26 03:55:42 +02:00
|
|
|
plugins: isDev ? [
|
2018-07-26 01:38:47 +02:00
|
|
|
new FilewatcherPlugin({
|
|
|
|
watchFileRegex: [require.resolve('lbry-redux')],
|
|
|
|
}),
|
2018-07-26 03:55:42 +02:00
|
|
|
] : [],
|
2017-12-09 14:23:40 +01:00
|
|
|
};
|