Created
April 22, 2020 08:19
-
-
Save Haroenv/26d99ba695db44fb1dbc9e8b5b024d3b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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