Skip to content

Instantly share code, notes, and snippets.

@Chett23
Created February 21, 2020 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chett23/11496ff58e993b2a10a764fc80cfbaac to your computer and use it in GitHub Desktop.
Save Chett23/11496ff58e993b2a10a764fc80cfbaac to your computer and use it in GitHub Desktop.
Webpack common
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
devtool: "inline-source-map",
output: {
path: path.resolve("dist", "assets"),
filename: "bundle.js"
},
performance: { hints: false },
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
include: path.resolve(__dirname, 'src'),
use: {
loader: "babel-loader",
}
},
{
test: /\.(s*)css$/,
use: [
{
loader: "style-loader" // Creates style nodes from JS strings.
},
{
loader: "css-loader", // Translates CSS into CommonJS.
options: {
sourceMap: true
}
}
]
},
{
test: /\.svg$/,
use: ["@svgr/webpack"]
}
]
},
externals: {
zendesk_app_framework_sdk: "ZAFClient"
},
resolve: {
alias: {
"@zafClient": path.resolve(__dirname, "src/api/zafClient.js"),
"@Components": path.resolve(__dirname, "src/Components"),
"@styledComponents": path.resolve(
__dirname,
"src/Components/styled-components"
),
"@globalConstants": path.resolve(__dirname, "src/globalConstants.js")
}
},
plugins: [
new HtmlWebpackPlugin({
template: "src/index.html",
hash: true
})
]
};
@Chett23
Copy link
Author

Chett23 commented Feb 21, 2020

webpack.prod.js

const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const TerserPlugin = require('terser-webpack-plugin');


module.exports = merge(common, {
	mode: 'production',
	optimization: {
    minimizer: [new TerserPlugin()],
	},
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment