Skip to content
Snippets Groups Projects
Select Git revision
  • bf12fe5b47ea62aeb796d22dc5eae830809c68d5
  • master default protected
  • v1.0.23
  • v1.0.19
  • v1.0.35
  • v1.0.18
  • v1.0.15
  • v1.0.12
  • v1.0.11
  • v.1.0.10
  • v1.0.9
  • v1.0.8
  • v1.0.7
  • v1.0.2
  • v1.0.1
15 results

webpack.js

Blame
  • user avatar
    Andrea Gottsponer authored
    bf12fe5b
    History
    webpack.js 3.51 KiB
    const path = require('path');
    const HtmlWebpackPlugin = require('html-webpack-plugin');
    const distPath = path.resolve(__dirname, 'dist');
    
    /*
    const webpack = require('webpack');
    const HtmlWebpackPlugin = require('html-webpack-plugin');
    
    const outputDir = 'dist_example';
    const publicPath = '/';
    const tsConfig = 'tsconfig_example.json';
     */
    
    module.exports = {
        entry: "./src/app/index.ts",
        mode: 'development',
        devtool: 'inline-source-map',
        module: {
            rules: [
                {
                    test: /\.tsx?$/,
                    use: 'ts-loader',
                    exclude: /node_modules/
                }
            ]
        },
        plugins: [
            new HtmlWebpackPlugin({
                title: 'Medsurf PIXI',
                template: 'src/public/index.html',
                hash: true,
                minify: {
                    collapseWhitespace: true,
                    removeComments: true,
                    removeRedundantAttributes: true,
                    removeScriptTypeAttributes: true,
                    removeStyleLinkTypeAttributes: true,
                    useShortDoctype: true
                }
            })
        ],
        resolve: {
            extensions: [ '.tsx', '.ts', '.js' ]
        },
        output: {
            filename: 'main.js',
            path: distPath
        },
        devServer: {
            static: distPath,
            compress: true,
            port: 9000
        }
        /*
        output: {
            path: path.resolve(__dirname, outputDir),
            filename: '[name].bundle.js',
            publicPath: publicPath,
            crossOriginLoading: 'anonymous'
        },
        devtool: 'source-map',
        mode: 'development',
        module: {
            rules: [
                {
                    test: /\.js$/,
                    loader: 'babel-loader',
                    exclude: /node_modules/,
                },
                {
                    test: /\.tsx?$/,
                    use: [
                        {
                            loader: 'ts-loader',
                            options: {
                                configFile: tsConfig
                            }
                        }
                    ],
                    exclude: /node_modules/
                },
                {
                    test: /\.mjs$/,
                    include: /node_modules/,
                    type: 'javascript/auto'
                }
            ]
        },
        plugins: [
            new HtmlWebpackPlugin({
                title: 'Medsurf PIXI',
                template: 'src/public/index.html',
                hash: true,
                minify: {
                    collapseWhitespace: true,
                    removeComments: true,
                    removeRedundantAttributes: true,
                    removeScriptTypeAttributes: true,
                    removeStyleLinkTypeAttributes: true,
                    useShortDoctype: true
                }
            }),
            new webpack.ProvidePlugin({
                PIXI: 'pixi.js-legacy'
            }),
        ],
        node: {
            net: 'empty',
            tls: 'empty',
            dns: 'empty',
            fs: 'empty',
        },
        resolve: {
            extensions: ['.js', '.ts', '.tsx', '.css', '.scss', '.json', '.mjs'],
            modules: ['node_modules'],
            plugins: []
        },
        stats: 'verbose',
        devServer: {
            contentBase: path.join(__dirname, outputDir),
            compress: false,
            host: '0.0.0.0',
            port: 9000,
            publicPath: publicPath,
            https: false,
            overlay: {
                warnings: true,
                errors: true
            },
            historyApiFallback: true,
            headers: {
                "Access-Control-Allow-Origin": "*",
                "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
            }
        }
        */
    };