2022-02-23 22:23:56 +01:00
|
|
|
// Generated using webpack-cli https://github.com/webpack/webpack-cli
|
|
|
|
|
|
|
|
const path = require('path');
|
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
|
|
|
|
|
const isProduction = process.env.NODE_ENV == 'production';
|
2022-02-28 22:37:50 +01:00
|
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
|
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
2022-02-23 22:23:56 +01:00
|
|
|
const stylesHandler = 'style-loader';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const config = {
|
|
|
|
entry: [
|
|
|
|
'./src/index.ts',
|
2022-02-25 21:26:12 +01:00
|
|
|
'./src/sass/player.sass',
|
2022-02-23 22:23:56 +01:00
|
|
|
],
|
|
|
|
devtool: 'inline-source-map',
|
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, 'dist'),
|
2022-02-28 22:37:50 +01:00
|
|
|
filename: isProduction ? '[name]-[chunkhash:6].js' : '[name].js',
|
2022-02-23 22:23:56 +01:00
|
|
|
},
|
|
|
|
devServer: {
|
|
|
|
open: true,
|
|
|
|
host: 'localhost',
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: ['.tsx', '.ts', '.js'],
|
|
|
|
fallback: {
|
|
|
|
// make it shut up about missing nodejs plugins in the browser
|
|
|
|
util: false,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: 'index.html',
|
|
|
|
}),
|
2022-02-28 22:37:50 +01:00
|
|
|
// Turn this on only when you need an overview about the bundle contents
|
|
|
|
// new BundleAnalyzerPlugin(),
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: isProduction ? 'stylesheets/[name]-[contenthash:6].css' : 'stylesheets/[name].css',
|
|
|
|
}),
|
2022-02-23 22:23:56 +01:00
|
|
|
// new NodePolyfillPlugin({
|
|
|
|
// excludeAliases: ['console'],
|
|
|
|
// }),
|
|
|
|
// Add your plugins here
|
|
|
|
// Learn more about plugins from https://webpack.js.org/configuration/plugins/
|
|
|
|
],
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.(js|jsx)$/i,
|
|
|
|
loader: 'babel-loader',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(ts|tsx)$/i,
|
|
|
|
use: 'ts-loader',
|
|
|
|
exclude: /node_modules/,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.s[ac]ss$/i,
|
2022-02-28 22:37:50 +01:00
|
|
|
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'sass-loader'],
|
2022-02-23 22:23:56 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/i,
|
|
|
|
use: [stylesHandler, 'css-loader', 'postcss-loader'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(eot|svg|ttf|woff|woff2|png|jpg|gif)$/i,
|
|
|
|
type: 'asset',
|
|
|
|
},
|
|
|
|
|
|
|
|
// Add your rules for custom modules here
|
|
|
|
// Learn more about loaders from https://webpack.js.org/loaders/
|
|
|
|
],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = () => {
|
|
|
|
if (isProduction) {
|
|
|
|
config.mode = 'production';
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
config.mode = 'development';
|
|
|
|
}
|
|
|
|
return config;
|
|
|
|
};
|