You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
807 B
41 lines
807 B
const webpack = require('webpack')
|
|
const { execSync } = require('child_process')
|
|
const path = require('path')
|
|
|
|
let hash = execSync('git rev-parse --short HEAD').toString().trim()
|
|
|
|
let plugins = []
|
|
let devtool = 'source-map'
|
|
|
|
if (process.env.ESP_PROD) {
|
|
// ignore demo
|
|
plugins.push(new webpack.IgnorePlugin(/\.\/demo(?:\.js)?$/))
|
|
|
|
// no source maps
|
|
devtool = ''
|
|
}
|
|
|
|
plugins.push(new webpack.optimize.UglifyJsPlugin({
|
|
sourceMap: devtool === 'source-map'
|
|
}))
|
|
|
|
module.exports = {
|
|
entry: './js',
|
|
output: {
|
|
path: path.resolve(__dirname, 'out', 'js'),
|
|
filename: `app.${hash}.js`
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.js$/,
|
|
exclude: [
|
|
path.resolve(__dirname, 'node_modules')
|
|
],
|
|
loader: 'babel-loader'
|
|
}
|
|
]
|
|
},
|
|
devtool,
|
|
plugins
|
|
}
|
|
|