2019-03-05 05:46:57 +01:00
|
|
|
const path = require('path');
|
|
|
|
const merge = require('webpack-merge');
|
|
|
|
const { DefinePlugin, ProvidePlugin } = require('webpack');
|
2019-03-09 01:19:29 +01:00
|
|
|
const { getIfUtils, removeEmpty } = require('webpack-config-utils');
|
|
|
|
|
2019-03-12 20:53:55 +01:00
|
|
|
const NODE_ENV = process.env.NODE_ENV || 'development';
|
|
|
|
|
|
|
|
const { ifProduction } = getIfUtils(NODE_ENV);
|
2019-03-05 05:46:57 +01:00
|
|
|
|
|
|
|
const UI_ROOT = path.resolve(__dirname, 'src/ui/');
|
|
|
|
const STATIC_ROOT = path.resolve(__dirname, 'static/');
|
|
|
|
const DIST_ROOT = path.resolve(__dirname, 'dist/');
|
|
|
|
|
|
|
|
const baseConfig = {
|
2019-03-09 01:19:29 +01:00
|
|
|
mode: ifProduction('production', 'development'),
|
|
|
|
devtool: ifProduction('source-map', 'eval-source-map'),
|
2019-03-05 05:46:57 +01:00
|
|
|
node: {
|
|
|
|
__dirname: false,
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.jsx?$/,
|
2019-03-08 20:20:17 +01:00
|
|
|
exclude: /node_modules/,
|
2019-03-05 05:46:57 +01:00
|
|
|
loader: 'babel-loader',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.scss$/,
|
|
|
|
use: [
|
|
|
|
'style-loader', // creates style nodes from JS strings
|
|
|
|
'css-loader', // translates CSS into CommonJS
|
|
|
|
'sass-loader', // compiles Sass to CSS, using Node Sass by default
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(png|svg|gif)$/,
|
|
|
|
use: {
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
2019-03-06 18:04:26 +01:00
|
|
|
outputPath: 'ui/img',
|
2019-03-05 05:46:57 +01:00
|
|
|
name: '[name].[ext]',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// font/inter includes a basic css file applying the fonts
|
|
|
|
// Everywhere else we use .scss
|
|
|
|
test: /\.(css|woff|woff2)$/,
|
|
|
|
use: {
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
outputPath: 'ui/font',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-03-07 04:37:25 +01:00
|
|
|
{
|
|
|
|
test: /\.glsl/,
|
|
|
|
use: {
|
|
|
|
loader: 'file-loader',
|
2019-03-08 20:20:17 +01:00
|
|
|
options: {
|
|
|
|
outputPath: 'ui/three',
|
|
|
|
},
|
2019-03-07 04:37:25 +01:00
|
|
|
},
|
|
|
|
},
|
2019-03-05 05:46:57 +01:00
|
|
|
],
|
|
|
|
},
|
|
|
|
// Allows imports for all directories inside '/ui'
|
|
|
|
resolve: {
|
|
|
|
modules: [UI_ROOT, 'node_modules', __dirname],
|
|
|
|
extensions: ['.js', '.jsx', '.json', '.scss'],
|
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [
|
|
|
|
new ProvidePlugin({
|
|
|
|
i18n: ['i18n', 'default'],
|
|
|
|
__: ['i18n/__', 'default'],
|
|
|
|
__n: ['i18n/__n', 'default'],
|
|
|
|
}),
|
|
|
|
new DefinePlugin({
|
|
|
|
__static: `"${path.join(__dirname, 'static').replace(/\\/g, '\\\\')}"`,
|
2019-03-12 20:53:55 +01:00
|
|
|
'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
|
2019-03-08 21:12:20 +01:00
|
|
|
'process.env.SDK_API_URL': JSON.stringify(process.env.SDK_API_URL),
|
2019-03-12 20:53:55 +01:00
|
|
|
'process.env.LBRY_API_URL': JSON.stringify(process.env.LBRY_API_URL),
|
2019-03-05 05:46:57 +01:00
|
|
|
}),
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = baseConfig;
|