lbry-desktop/lbrytv/webpack.config.js

103 lines
2.5 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');
2020-02-04 20:37:17 +01:00
const SentryWebpackPlugin = require('@sentry/webpack-plugin');
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;
2020-02-04 20:37:17 +01:00
const hasSentryToken = process.env.SENTRY_AUTH_TOKEN !== undefined;
let plugins = [
new CopyWebpackPlugin([
{
from: `${STATIC_ROOT}/index-web.html`,
to: `${DIST_ROOT}/index.html`,
},
{
from: `${STATIC_ROOT}/img/favicon.png`,
to: `${DIST_ROOT}/public/favicon.png`,
},
{
from: `${STATIC_ROOT}/img/v1-og.png`,
to: `${DIST_ROOT}/public/v1-og.png`,
},
{
from: `${STATIC_ROOT}/font/`,
to: `${DIST_ROOT}/public/font/`,
},
]),
new DefinePlugin({
IS_WEB: JSON.stringify(true),
'process.env.SDK_API_URL': JSON.stringify(process.env.SDK_API_URL || LBRY_TV_API),
}),
new ProvidePlugin({
__: ['i18n.js', '__'],
}),
];
if (hasSentryToken) {
plugins.push(
new SentryWebpackPlugin({
include: './dist',
ignoreFile: '.sentrycliignore',
ignore: ['node_modules', 'webpack.config.js'],
configFile: 'sentry.properties',
})
);
}
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',
2020-02-04 20:37:17 +01:00
path: path.join(__dirname, 'dist/public/'),
publicPath: '/public/',
2019-03-05 05:46:57 +01:00
},
devServer: {
port: WEBPACK_WEB_PORT,
2019-12-13 22:46:28 +01:00
contentBase: path.join(__dirname, 'dist'),
},
2019-03-05 05:46:57 +01:00
module: {
rules: [
{
2019-11-07 20:39:22 +01:00
loader: 'babel-loader',
test: /\.jsx?$/,
options: {
2019-11-21 22:48:19 +01:00
presets: ['@babel/env', '@babel/react', '@babel/flow'],
plugins: ['@babel/plugin-proposal-object-rest-spread', '@babel/plugin-proposal-class-properties'],
2019-11-07 20:39:22 +01:00
},
},
{
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
},
},
2020-02-04 20:37:17 +01:00
plugins,
2019-03-05 05:46:57 +01:00
};
module.exports = merge(baseConfig, webConfig);