Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const path = require('path');
- const webpack = require('webpack');
- const HtmlWebpackPlugin = require('html-webpack-plugin');
- const CopyWebpackPlugin = require('copy-webpack-plugin');
- const { CleanWebpackPlugin } = require('clean-webpack-plugin');
- const env = require('./config');
- const NODE_ENV = process.env.NODE_ENV || 'production';
- const WORKDIR = __dirname;
- const publicPath = path.resolve(WORKDIR, 'dist');
- let config = {
- mode: NODE_ENV,
- entry: {
- client: path.resolve(WORKDIR, 'src/index.jsx'),
- },
- output: {
- filename: 'js/[name].bundle.js',
- chunkFilename: 'js/[name].chunkhash.bundle.js',
- publicPath: '/',
- path: publicPath,
- library: '[name]',
- },
- optimization: {
- splitChunks: {
- cacheGroups: {
- commons: {
- test: /[\\/]node_modules[\\/]/,
- name: 'vendor',
- chunks: 'all'
- },
- }
- },
- runtimeChunk: true
- },
- devtool: NODE_ENV === 'production' ? false : 'source-map',
- module: {
- rules: [
- {
- test: /\.jsx?$/,
- exclude: /node_modules/,
- use: ["babel-loader", "eslint-loader"]
- },
- {test: /\.(png|jpg|gif|svg)$/, loader: 'file-loader?name=img/[name]-[sha512:hash:base64:7].[ext]'},
- {
- test: /\.(ttf|otf|eot|woff(2)?)(\?[a-z0-9]+)?$/,
- loader: 'file-loader?name=fonts/[name]-[sha512:hash:base64:7].[ext]'
- }
- ]
- },
- resolve: {
- extensions: ['*', '.js', '.jsx'],
- alias: {
- stylesheet: path.resolve(__dirname, 'src/common/Theme'),
- mediaQuery: path.resolve(__dirname, 'src/utils/MediaQuery'),
- },
- },
- plugins: [
- new CleanWebpackPlugin(),
- new webpack.EnvironmentPlugin(env),
- new CopyWebpackPlugin([
- // {from: './src/common/components/Icon/assets/icons', to: 'public/icons'},
- // {from: './src/assets/favicons', to: ''},
- // {from: './src/assets/images', to: 'public/images'},
- ]),
- new HtmlWebpackPlugin({
- title: "Lvle Up Portal",
- filename: path.resolve(WORKDIR, 'dist/index.html'),
- template: path.resolve(WORKDIR, 'src/index.ejs'),
- hash: true,
- cache: NODE_ENV === 'production'
- })
- ],
- devServer: {
- historyApiFallback: true
- }
- };
- module.exports = config;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement