lbry-desktop/lbrytv/webpack.config.js

88 lines
2.2 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',
path: __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
},
},
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
{
2019-12-05 18:58:10 +01:00
from: `${STATIC_ROOT}/img/favicon.png`,
to: `${DIST_ROOT}/public/favicon.png`,
2019-03-08 20:20:17 +01:00
},
2019-04-18 20:32:58 +02:00
{
from: `${STATIC_ROOT}/img/og.png`,
to: `${DIST_ROOT}/public/og.png`,
2019-03-06 18:04:26 +01:00
},
2019-12-05 20:15:40 +01:00
{
from: `${STATIC_ROOT}/font/`,
to: `${DIST_ROOT}/public/font/`,
2019-12-05 20:15:40 +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);