Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const path = require('path');
- const webpack = require('webpack');
- const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
- const HtmlWebpackPlugin = require('html-webpack-plugin');
- const MiniCssExtractPlugin = require('mini-css-extract-plugin');
- const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
- // const isProduction = process.env.NODE_ENV === 'production';
- module.exports = {
- target: 'web',
- entry: {
- main: path.resolve(__dirname, 'src', 'index.jsx'),
- },
- output: {
- path: path.resolve(__dirname, 'dist'),
- filename: '[name].[chunkhash].js',
- publicPath: '/',
- },
- module: {
- rules: [
- {
- test: /\.jsx?$/,
- exclude: /node_modules(?!\/myuimodule)/,
- use: ['babel-loader'],
- },
- {
- test: /\.s?[ac]ss$/,
- use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'sass-loader'],
- },
- {
- test: /\.(png|svg|jpg|gif)$/,
- use: ['file-loader'],
- },
- {
- test: /\.(woff|woff2|eot|ttf|otf)$/,
- use: ['file-loader'],
- },
- ],
- },
- plugins: [
- new webpack.DefinePlugin({
- 'process.env': {
- NODE_ENV: JSON.stringify(process.env.NODE_ENV),
- },
- }),
- new HtmlWebpackPlugin({
- inject: false,
- template: path.join('src', 'index.html'),
- title: 'Title',
- }),
- new MiniCssExtractPlugin({
- filename: '[name].[contenthash].css',
- chunkFilename: '[name].[contenthash].chunk.css',
- }),
- ],
- resolve: {
- extensions: ['.js', '.jsx', '.css', '.scss'],
- },
- devServer: {
- stats: 'minimal',
- historyApiFallback: true,
- contentBase: path.resolve(__dirname, 'dist'),
- proxy: {
- '/api': 'http://localhost:5000',
- },
- },
- optimization: {
- occurrenceOrder: true,
- runtimeChunk: true,
- splitChunks: {
- cacheGroups: {
- vendors: {
- chunks: 'all',
- name: 'vendor',
- test: 'vendor',
- enforce: true,
- },
- },
- },
- minimizer: [new UglifyJsPlugin({}), new OptimizeCSSAssetsPlugin({})],
- },
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement