<commit_before>const path = require('path');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const SveltePreprocess = require('svelte-preprocess');

module.exports = [
    {
        entry: './src/js/HuesCore.ts',
        mode: 'production',
        devtool: 'source-map',
        output: {
            filename: 'lib/hues-min.js',
            path: path.resolve(__dirname, 'dist'),
            assetModuleFilename: '[path][name][ext][query]'
        },
        performance: {
            hints: false,
        },
        module: {
            rules: [
                {
                    test: /\.svelte$/,
                    use: {
                        loader: 'svelte-loader',
                        options: {
                            preprocess: SveltePreprocess()
                        }
                    }
                },
                {
                    test: /\.tsx?$/,
                    loader: "ts-loader",
                    exclude: /node_modules/
                },
                {
                    test: /\.js$/,
                    loader: "source-map-loader"
                },
                {
                    test: /.s?css$/,
                    use: [MiniCssExtractPlugin.loader, "css-loader"],//, "sass-loader"],
                },
                {
                    test: /\.(png|jpe?g|gif|eot|svg|ttf|woff|ico|html)$/i,
                    type: 'asset/resource',
                },
                // audio worker + sources should just be copied as-is
                {
                    test: /(audio-worker|mpg123|ogg|vorbis)\.js$/,
                    type: 'asset/resource',
                },
            ],
        },
        resolve: {
            extensions: ['.tsx', '.ts', '.js'],
        },
        optimization: {
            minimizer: [
                `...`,
                new CssMinimizerPlugin(),
            ],
        },
        plugins: [new MiniCssExtractPlugin({
            filename: 'css/hues-min.css',
        })],
    },
    // audio workers are lazy-loaded so get compiled separately
    {
        entry: './src/js/audio/aurora.js',
        mode: 'production',
        output: {
            filename: 'lib/audio-min.js',
            path: path.resolve(__dirname, 'dist'),
        },
        performance: {
            hints: false,
        },
        module: {
            rules: [
                // audio worker + sources should just be copied as-is<commit_msg>Don't minimize when running dev server, much faster<commit_after>const path = require('path');
const process = require('process');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const SveltePreprocess = require('svelte-preprocess');

const isDevServer = process.env.WEBPACK_SERVE;

let optimization;
if(isDevServer) {
    optimization = {
        minimize: false
    };
} else {
    optimization = {
        minimizer: [
            `...`,
            new CssMinimizerPlugin(),
        ],
    };
}

module.exports = [
    {
        entry: './src/js/HuesCore.ts',
        mode: 'production',
        devtool: 'source-map',
        output: {
            filename: 'lib/hues-min.js',
            path: path.resolve(__dirname, 'dist'),
            assetModuleFilename: '[path][name][ext][query]'
        },
        performance: {
            hints: false,
        },
        module: {
            rules: [
                {
                    test: /\.svelte$/,
                    use: {
                        loader: 'svelte-loader',
                        options: {
                            preprocess: SveltePreprocess()
                        }
                    }
                },
                {
                    test: /\.tsx?$/,
                    loader: "ts-loader",
                    exclude: /node_modules/
                },
                {
                    test: /\.js$/,
                    loader: "source-map-loader"
                },
                {
                    test: /.s?css$/,
                    use: [MiniCssExtractPlugin.loader, "css-loader"],//, "sass-loader"],
                },
                {
                    test: /\.(png|jpe?g|gif|eot|svg|ttf|woff|ico|html)$/i,
                    type: 'asset/resource',
                },
                // audio worker + sources should just be copied as-is
                {
                    test: /(audio-worker|mpg123|ogg|vorbis)\.js$/,
                    type: 'asset/resource',
                },
            ],
        },
        resolve: {
            extensions: ['.tsx', '.ts', '.js'],
        },
        optimization: optimization,
        plugins: [new MiniCssExtractPlugin({
            filename: 'css/hues-min.css',
        })],
    },
    // audio workers are lazy-loaded so get compiled separately
    {
        entry: './src/js/audio/aurora.js',
        mode: 'production',
        output: {
            filename: 'lib/audio-min.js',
            path: path.resolve(__dirname, 'dist'),
        },
        performance: {
            hints: false,
        },
        module: {
            rules: [
                // audio worker + sources should just be copied as-is
{'fraction_non_alphanumeric': 0.13278164378408877, 'fraction_numerical': 0.0011284558961820576, 'mean_word_length': 1.099486774575602, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4778661', 'n_tokens_mistral': 1463, 'n_tokens_neox': 1398, 'n_words': 255}