lbry-desktop/lbrytv/webpack.config.js

83 lines
1.9 KiB
JavaScript
Raw Normal View History

2019-11-07 20:39:22 +01:00
const { WEBPACK_WEB_PORT, LBRY_TV_API } = require('../config.js');
2019-03-05 05:46:57 +01:00
const path = require('path');
const merge = require('webpack-merge');
2019-11-07 20:39:22 +01:00
const baseConfig = require('../webpack.base.config.js');
2019-03-05 05:46:57 +01:00
const CopyWebpackPlugin = require('copy-webpack-plugin');
2019-09-26 17:06:01 +02:00
const { DefinePlugin, ProvidePlugin } = require('webpack');
2019-03-05 05:46:57 +01:00
2019-11-07 20:39:22 +01:00
const STATIC_ROOT = path.resolve(__dirname, '../static/');
2019-11-11 16:22:57 +01:00
const UI_ROOT = path.resolve(__dirname, '../ui/');
2019-03-05 05:46:57 +01:00
const DIST_ROOT = path.resolve(__dirname, 'dist/');
2019-11-07 20:39:22 +01:00
const WEB_PLATFORM_ROOT = __dirname;
2019-03-05 05:46:57 +01:00
const webConfig = {
target: 'web',
entry: {
2019-11-07 20:39:22 +01:00
ui: '../ui/index.jsx',
2019-03-05 05:46:57 +01:00
},
output: {
2019-03-05 18:54:11 +01:00
filename: '[name].js',
2019-11-07 20:39:22 +01:00
path: __dirname + '/dist/',
2019-04-01 18:11:20 +02:00
publicPath: '/',
2019-03-05 05:46:57 +01:00
},
devServer: {
port: WEBPACK_WEB_PORT,
},
2019-03-05 05:46:57 +01:00
module: {
rules: [
{
2019-11-07 20:39:22 +01:00
loader: 'babel-loader',
test: /\.jsx?$/,
exclude: /node_modules/,
options: {
rootMode: 'upward',
},
},
{
loader: 'preprocess-loader',
test: /\.jsx?$/,
exclude: /node_modules/,
options: {
TARGET: 'web',
ppOptions: {
type: 'js',
2019-03-05 05:46:57 +01:00
},
2019-11-07 20:39:22 +01:00
},
2019-03-05 05:46:57 +01:00
},
],
},
resolve: {
2019-11-11 16:22:57 +01:00
modules: [UI_ROOT, __dirname],
2019-03-05 05:46:57 +01:00
alias: {
2019-11-07 20:39:22 +01:00
electron: `${WEB_PLATFORM_ROOT}/stubs/electron.js`,
fs: `${WEB_PLATFORM_ROOT}/stubs/fs.js`,
2019-03-05 05:46:57 +01:00
},
},
plugins: [
new CopyWebpackPlugin([
{
from: `${STATIC_ROOT}/index-web.html`,
2019-11-07 20:39:22 +01:00
to: `${DIST_ROOT}/index.html`,
2019-03-05 05:46:57 +01:00
},
2019-03-08 20:20:17 +01:00
{
from: `${STATIC_ROOT}/img/favicon.ico`,
2019-11-07 20:39:22 +01:00
to: `${DIST_ROOT}/favicon.ico`,
2019-03-08 20:20:17 +01:00
},
2019-04-18 20:32:58 +02:00
{
from: `${STATIC_ROOT}/img/og.png`,
2019-11-07 20:39:22 +01:00
to: `${DIST_ROOT}/og.png`,
2019-03-06 18:04:26 +01:00
},
2019-03-05 05:46:57 +01:00
]),
2019-03-18 06:06:41 +01:00
new DefinePlugin({
IS_WEB: JSON.stringify(true),
'process.env.SDK_API_URL': JSON.stringify(process.env.SDK_API_URL || LBRY_TV_API),
2019-03-18 06:06:41 +01:00
}),
2019-09-26 17:06:01 +02:00
new ProvidePlugin({
__: ['i18n.js', '__'],
}),
2019-03-05 05:46:57 +01:00
],
};
module.exports = merge(baseConfig, webConfig);