lbry-desktop/webpack.web.config.js

77 lines
1.8 KiB
JavaScript
Raw Normal View History

const { WEBPACK_WEB_PORT } = require('./config.js');
2019-03-05 05:46:57 +01:00
const path = require('path');
const merge = require('webpack-merge');
const baseConfig = require('./webpack.base.config.js');
const CopyWebpackPlugin = require('copy-webpack-plugin');
2019-03-18 06:06:41 +01:00
const { DefinePlugin } = require('webpack');
2019-03-05 05:46:57 +01:00
const STATIC_ROOT = path.resolve(__dirname, 'static/');
const DIST_ROOT = path.resolve(__dirname, 'dist/');
2019-03-06 18:04:26 +01:00
const WEB_PLATFORM_ROOT = path.resolve(__dirname, 'src/platforms/web/');
2019-03-05 05:46:57 +01:00
const webConfig = {
target: 'web',
entry: {
ui: './src/ui/index.jsx',
2019-03-05 05:46:57 +01:00
},
output: {
2019-03-05 18:54:11 +01:00
filename: '[name].js',
2019-03-05 05:46:57 +01:00
path: __dirname + '/dist/web',
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-03-29 15:23:32 +01:00
test: /\.(jsx?$|s?css$)/,
2019-03-05 05:46:57 +01:00
use: [
{
loader: 'preprocess-loader',
options: {
TARGET: 'web',
ppOptions: {
type: 'js',
},
},
},
],
},
],
},
resolve: {
modules: [path.resolve(__dirname, 'src/platforms/')],
2019-06-11 20:10:58 +02:00
2019-03-05 05:46:57 +01:00
alias: {
2019-06-11 20:10:58 +02:00
electron: path.resolve(__dirname, 'src/platforms/web/stubs'),
2019-08-06 18:16:56 +02:00
fs: path.resolve(__dirname, 'src/platforms/web/fs'),
2019-03-05 05:46:57 +01:00
},
},
plugins: [
new CopyWebpackPlugin([
{
from: `${STATIC_ROOT}/index-web.html`,
2019-09-03 05:01:04 +02:00
to: `${DIST_ROOT}/web/index.html`,
2019-03-05 05:46:57 +01:00
},
2019-03-08 20:20:17 +01:00
{
from: `${STATIC_ROOT}/img/favicon.ico`,
to: `${DIST_ROOT}/web/favicon.ico`,
},
2019-04-18 20:32:58 +02:00
{
from: `${STATIC_ROOT}/img/og.png`,
to: `${DIST_ROOT}/web/og.png`,
},
2019-03-06 18:04:26 +01:00
{
from: `${WEB_PLATFORM_ROOT}/server.js`,
to: `${DIST_ROOT}/web/server.js`,
},
2019-03-05 05:46:57 +01:00
]),
2019-03-18 06:06:41 +01:00
new DefinePlugin({
IS_WEB: JSON.stringify(true),
}),
2019-03-05 05:46:57 +01:00
],
};
module.exports = merge(baseConfig, webConfig);