Skip to content

Instantly share code, notes, and snippets.

@Haroenv
Created April 22, 2020 08:19
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 Haroenv/26d99ba695db44fb1dbc9e8b5b024d3b to your computer and use it in GitHub Desktop.
Save Haroenv/26d99ba695db44fb1dbc9e8b5b024d3b to your computer and use it in GitHub Desktop.
const path = require('path');
const webpack = require('webpack');
const isProd = process.env.NODE_ENV === 'production';
module.exports = [
{
name: 'plugin',
entry: {
// replace this with your source file
algolia: path.join(
process.cwd(),
'public/shopify/assets/javascripts/v4/externals.js'
),
},
output: {
// replace this with your output folder
path: path.resolve(process.cwd(), 'public/shopify/assets/javascripts/v4'),
filename: 'algolia_externals.js',
library: 'algoliaShopify.externals',
libraryTarget: 'assign',
},
devtool: isProd ? false : 'cheap-module-inline-source-map',
module: {
rules: [
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
},
],
},
target: 'web',
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
},
}),
isProd &&
new webpack.optimize.UglifyJsPlugin({
test: /\.js/i,
compress: {
warnings: false,
screw_ie8: true,
conditionals: true,
unused: true,
comparisons: true,
sequences: true,
dead_code: true,
evaluate: true,
if_return: true,
join_vars: true,
},
output: {
comments: false,
},
}),
].filter(Boolean),
},
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment