CoolFace
Apppublic

exbert-project/exbert

sourceHugging Faceapache-2.0updated 3y agoView on Hugging Face
183likes
webpack.config.js142 linesDownload Raw Back to src
1const path = require('path');2const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');3const MiniCssExtractPlugin = require("mini-css-extract-plugin");4const CopyWebpackPlugin = require('copy-webpack-plugin');5 6module.exports = {7    entry: {8        main: './ts/main.ts',9        // captioning: './ts/captioning.ts'10    },11    module: {12        rules: [13            {14                test: /\.tsx?$/,15                exclude: [16                    /node_modules/,17                    /ImageContentBox\.ts/,18                    /test\.ts/19                    // path.resolve(__dirname,'ts/vis/ImageContentBox.ts')20                ],21                use: [{22                    loader: 'cache-loader'23                },24                    {25                        loader: 'thread-loader',26                        options: {27                            // there should be 1 cpu for the fork-ts-checker-webpack-plugin28                            workers: require('os').cpus().length - 1,29                        },30                    },31                    {32                        loader: 'ts-loader',33                        options: {34                            happyPackMode: true // IMPORTANT! use happyPackMode mode to speed-up  compilation and reduce errors reported to webpack35                        }36                    }37                ].slice(process.env.CI ? 2 : 0) // no optimizations for CIs38            },39            {40                test: /\.s?css$/,41                use: [42                    {43                        loader: MiniCssExtractPlugin.loader,44                        options: {45                            // you can specify a publicPath here46                            // by default it use publicPath in webpackOptions.output47                            // publicPath: '../'48 49                        }50                    },51                    {52                        loader: 'css-loader',53                        options: {54                            minimize: true,55                            sourceMap: true56                        }57                    },58                    {59                        loader: 'sass-loader',60                        options: {61                            sourceMap: true62                        }63                    }64                ]65 66            },67            {68                test: /\.(png|jpg)$/,69                loader: 'url-loader',70                options: {71                    limit: 20000 //inline <= 10kb72                }73            },74            {75                test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,76                loader: 'url-loader',77                options: {78                    limit: 20000, //inline <= 20kb79                    mimetype: 'application/font-woff'80                }81            },82            {83                test: /\.svg(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,84                loader: 'url-loader',85                options: {86                    limit: 10000, //inline <= 10kb87                    mimetype: 'image/svg+xml'88                }89            },90            {91                test: /\.(ttf|eot)(\?v=[0-9]\.[0-9]\.[0-9])?$/,92                loader: 'file-loader'93            }94        ]95    },96    resolve: {97        extensions: ['.ts', '.js']98    },99    plugins: [100        new MiniCssExtractPlugin({101            // Options similar to the same options in webpackOptions.output102            // both options are optional103            // filename: "style.css",104            // chunkFilename: "chunk.css"105        }),106        new ForkTsCheckerWebpackPlugin({107            checkSyntacticErrors: true108        }),109        new CopyWebpackPlugin([110            {from: 'img', to: 'img'},111            {from: "demo", to:"demo"}112        ]),113    ],114    optimization: {115        splitChunks: {116            cacheGroups: {117                vendor: {118                    test: /node_modules/,119                    chunks: "initial",120                    name: "vendor",121                    priority: 10,122                    enforce: true123                }124            }125        }126    },127    output: {128        filename: '[name].js',129        path: path.resolve(__dirname, '../dist/')130    },131    devServer: {132        port: 8090,133        proxy: {134            '/api/*': {135                target: 'http://localhost:8080',136                secure: false,137                ws: true138            }139        }140    }141};142