lbry-desktop/webpack.electron.config.js

110 lines
2.3 KiB
JavaScript
Raw Normal View History

2019-03-05 05:46:57 +01:00
const path = require('path');
2019-03-13 07:52:14 +01:00
const webpack = require('webpack');
2019-03-05 05:46:57 +01:00
const merge = require('webpack-merge');
const baseConfig = require('./webpack.base.config.js');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const STATIC_ROOT = path.resolve(__dirname, 'static/');
const DIST_ROOT = path.resolve(__dirname, 'dist/');
2019-03-05 07:24:03 +01:00
const mainConfig = {
target: 'electron-main',
2019-03-05 05:46:57 +01:00
entry: {
main: './src/platforms/electron/index.js',
2019-03-05 07:24:03 +01:00
},
output: {
2019-03-05 08:47:55 +01:00
filename: '[name].js',
2019-03-05 07:24:03 +01:00
path: __dirname + '/dist/electron',
},
module: {
rules: [
{
test: /\.node$/,
use: 'node-loader',
},
{
test: /\.jsx?$/,
use: [
{
loader: 'preprocess-loader',
options: {
TARGET: 'app',
ppOptions: {
type: 'js',
},
},
},
],
},
],
},
plugins: [
new CopyWebpackPlugin([
{
from: `${STATIC_ROOT}/`,
to: `${DIST_ROOT}/electron/static/`,
ignore: ['font/**/*', 'index.html'],
},
{
from: `${STATIC_ROOT}/index.html`,
to: `${DIST_ROOT}/electron/index.html`,
},
]),
],
devServer: {
2019-03-05 18:54:11 +01:00
contentBase: path.join(__dirname, 'dist/electron'),
2019-03-05 07:24:03 +01:00
},
};
const renderConfig = {
target: 'electron-renderer',
entry: {
2019-03-13 07:52:14 +01:00
ui: ['./src/ui/index.jsx'],
2019-03-05 05:46:57 +01:00
},
output: {
2019-03-05 08:47:55 +01:00
filename: '[name].js',
2019-03-05 05:46:57 +01:00
path: __dirname + '/dist/electron',
},
module: {
rules: [
{
test: /\.node$/,
use: 'node-loader',
},
{
test: /\.jsx?$/,
use: [
{
loader: 'preprocess-loader',
options: {
TARGET: 'app',
ppOptions: {
type: 'js',
},
},
},
],
},
],
},
plugins: [
new CopyWebpackPlugin([
{
from: `${STATIC_ROOT}/`,
to: `${DIST_ROOT}/electron/static/`,
2019-03-05 18:54:11 +01:00
ignore: ['font/**/*', 'index.html', 'index.dev.html'],
2019-03-05 05:46:57 +01:00
},
{
from: `${STATIC_ROOT}/index.html`,
to: `${DIST_ROOT}/electron/index.html`,
},
2019-03-05 18:54:11 +01:00
{
from: `${STATIC_ROOT}/index.dev.html`,
to: `${DIST_ROOT}/electron/index.dev.html`,
},
2019-03-05 05:46:57 +01:00
]),
],
};
2019-03-05 18:54:11 +01:00
module.exports = [merge(baseConfig, mainConfig), merge(baseConfig, renderConfig)];