partey_workadventure/front/webpack.config.ts

99 lines
3.0 KiB
TypeScript
Raw Normal View History

import {Configuration} from "webpack";
import WebpackDevServer from "webpack-dev-server";
2020-04-03 14:56:21 +02:00
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
2020-04-03 14:56:21 +02:00
const mode = process.env.NODE_ENV ?? 'development';
const isProduction = mode === 'production';
const isDevelopment = !isProduction;
2020-04-03 14:56:21 +02:00
module.exports = {
entry: {
'main': './src/index.ts',
'iframe_api': './src/iframe_api.ts'
},
mode: mode,
devtool: isDevelopment ? 'inline-source-map' : 'source-map',
2020-04-03 14:56:21 +02:00
devServer: {
contentBase: './dist',
host: '0.0.0.0',
2021-05-13 16:13:07 +02:00
sockPort: 443,
disableHostCheck: true,
historyApiFallback: {
rewrites: [
{ from: /^_\/.*$/, to: '/index.html' }
],
disableDotRule: true
},
2020-04-03 14:56:21 +02:00
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.scss$/,
use: [MiniCssExtractPlugin.loader, 'css-loader?url=false', 'sass-loader'],
},
2020-04-03 14:56:21 +02:00
],
},
resolve: {
extensions: [ '.tsx', '.ts', '.js' ],
},
output: {
filename: (pathData) => {
// Add a content hash only for the main bundle.
// We want the iframe_api.js file to keep its name as it will be referenced from outside iframes.
return pathData.chunk?.name === 'main' ? 'js/[name].[contenthash].js': '[name].js';
},
2020-04-03 14:56:21 +02:00
path: path.resolve(__dirname, 'dist'),
publicPath: '/'
2020-04-03 14:56:21 +02:00
},
/*externals:[
require('webpack-require-http')
],*/
2020-04-03 14:56:21 +02:00
plugins: [
new MiniCssExtractPlugin({filename: 'style.[contenthash].css'}),
new HtmlWebpackPlugin(
{
template: './dist/index.tmpl.html.tmp',
minify: {
collapseWhitespace: true,
keepClosingSlash: true,
removeComments: false,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
useShortDoctype: true
},
chunks: ['main']
}
),
2020-04-03 14:56:21 +02:00
new webpack.ProvidePlugin({
Phaser: 'phaser'
}),
2021-03-31 16:20:11 +02:00
new webpack.EnvironmentPlugin({
'API_URL': null,
'PUSHER_URL': undefined,
'UPLOADER_URL': null,
'ADMIN_URL': null,
'DEBUG_MODE': null,
'STUN_SERVER': null,
'TURN_SERVER': null,
'TURN_USER': null,
'TURN_PASSWORD': null,
'JITSI_URL': null,
'JITSI_PRIVATE_MODE': null,
'START_ROOM_URL': null,
'MAX_USERNAME_LENGTH': 8,
'MAX_PER_GROUP': 4
2021-03-31 16:20:11 +02:00
})
2020-07-28 11:06:08 +02:00
],
} as Configuration & WebpackDevServer.Configuration;