{"size": 2317, "ext": "js", "max_stars_repo_path": "webpack.common.js", "max_stars_repo_name": "LinFan15/Webpack_PostCSS_Starter", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "webpack.common.js", "max_issues_repo_name": "LinFan15/Webpack_PostCSS_Starter", "max_issues_repo_issues_event_min_datetime": "2021-03-09T18:43:00.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-10T15:50:15.000Z", "max_forks_repo_path": "webpack.common.js", "max_forks_repo_name": "LinFan15/Webpack_PostCSS_Starter", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 31.7397260274, "max_line_length": 81, "alphanum_fraction": 0.4156236513}
const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const devMode = process.env.NODE_ENV.trim() !== "production";

const PATHS = {
    app: path.join(__dirname, 'src'),
    assets: path.join(__dirname, 'assets'),
    dist: path.join(__dirname, 'dist'),
};

module.exports = {
    entry: path.resolve(PATHS.app, 'main.js'),
    plugins: [
        new CleanWebpackPlugin(),
        new HtmlWebpackPlugin({
            title: 'Boggle - jQuery',
            template: path.resolve(PATHS.assets, 'index.html'),
            favicon: path.resolve(PATHS.assets, 'favicon.png'),
        }),
        new MiniCssExtractPlugin({
            filename: devMode ? '[name].css' : '[name].[hash].css',
            chunkFilename: devMode ? '[id].css' : '[id].[hash].css',
        }),
    ],
    module: {
        rules: [
            {
                test: /\.m?js$/,
                exclude: /(node_modules)/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ["@babel/preset-env"],
                    },
                },
            },
        ],
    },
    module: {
        rules: [
            {
                test: /\.css$/i,
                exclude: /(node_modules)/,
                use: [
                    {
                        loader: MiniCssExtractPlugin.loader,
                        options: {
                            hmr: devMode,
                            sourceMap: devMode
                        }
                    },
                    {
                        loader: 'css-loader',
                        options: {
                            importLoaders: 1,
                            sourceMap: devMode,
                        }
                    },
                    {
                        loader: 'postcss-loader', options: {sourceMap: devMode, }
                    }
                ],
            },
        ],
    },
    output: {
        filename: devMode ? '[name].bundle.js' : '[name].[hash].bundle.js',
        chunkFilename: devMode ? '[id].js' : '[id].[hash].js',
        path: path.resolve(PATHS.dist)
    },    
};