51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
'use strict'
|
|
|
|
const webpack = require('webpack')
|
|
const path = require('path')
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
|
const glb = require(path.join(__dirname, 'globals'))
|
|
|
|
module.exports = (env, options) => {
|
|
return {
|
|
entry: {
|
|
main: './src/js/main'
|
|
},
|
|
output: {
|
|
path: path.join(__dirname, 'app', 'public'),
|
|
filename: '[name].js'
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.js$/,
|
|
exclude: /(node_modules|bower_components)/,
|
|
use: {
|
|
loader: 'babel-loader',
|
|
options: {
|
|
presets: [ '@babel/preset-env' ]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
plugins: [
|
|
new webpack.ProvidePlugin({
|
|
// Detect and inject
|
|
_: 'underscore'
|
|
}),
|
|
new HtmlWebpackPlugin({
|
|
template: 'src/document/index.html'
|
|
}),
|
|
new CopyWebpackPlugin([{
|
|
from: 'static',
|
|
to: 'static'
|
|
}]),
|
|
new webpack.DefinePlugin({
|
|
globalConfig: JSON.stringify(glb.client)
|
|
})
|
|
],
|
|
devtool: (options.mode === 'development' ? 'inline-source-map' : undefined)
|
|
}
|
|
}
|