Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const HtmlWebpackPlugin = require("html-webpack-plugin");
- const webpack = require("webpack");
- const ExtractTextPlugin = require("extract-text-webpack-plugin");
- const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
- const path = require("path");
- require("dotenv").config();
- var configFunc = function(){
- var config = {
- optimization: {
- minimizer: [new UglifyJsPlugin()],
- splitChunks: {
- cacheGroups: {
- commons: {
- name: "commons",
- filename: "commons.js"
- }
- }
- }
- },
- devtool: "source-map",
- entry: [
- __dirname + "/app/app.js"
- ],
- output: {
- path: __dirname + "/dist",
- filename: "bundle.js",
- publicPath: "/"
- },
- devServer: {
- historyApiFallback: true,
- contentBase: './',
- hot: true
- },
- module: {
- rules: [
- {
- test: /\.js$/,
- use: "babel-loader",
- exclude: [/node_modules/]
- },
- {
- test: /\.(sass|scss|css)$/,
- use: [
- {
- loader: "style-loader" // creates style nodes from JS strings
- },
- {
- loader: "css-loader" // translates CSS into CommonJS
- }
- ]
- }
- ]
- },
- plugins: [
- new HtmlWebpackPlugin({
- hash: true,
- template: path.join(__dirname , "/app/index.html"),
- inject: "body"
- }),
- new webpack.BannerPlugin("React Twilio"),
- new ExtractTextPlugin("[name]-[hash].css")
- ]};
- if(process.env.NODE_ENV === "PROD") {
- config.plugins.push(new UglifyJsPlugin());
- }
- if(process.env.NODE_ENV === "DEV") {
- config.entry.push('webpack-hot-middleware/client?reload=true');
- config.plugins.push(new webpack.HotModuleReplacementPlugin());
- }
- return config;
- }();
- module.exports = configFunc;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement