2019-07-13 18:16:46 +00:00
|
|
|
const path = require('path');
|
|
|
|
const glob = require('glob');
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
|
|
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
|
|
|
|
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
|
|
|
|
|
|
module.exports = (env, options) => ({
|
|
|
|
optimization: {
|
|
|
|
minimizer: [
|
2019-07-31 11:16:53 +00:00
|
|
|
new UglifyJsPlugin({ cache: true, parallel: true, sourceMap: false }),
|
2019-07-13 18:16:46 +00:00
|
|
|
new OptimizeCSSAssetsPlugin({})
|
|
|
|
]
|
|
|
|
},
|
|
|
|
entry: {
|
|
|
|
'./js/app.js': glob.sync('./vendor/**/*.js').concat(['./js/app.js'])
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
filename: 'app.js',
|
|
|
|
path: path.resolve(__dirname, '../priv/static/js')
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
use: [MiniCssExtractPlugin.loader, 'css-loader']
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new MiniCssExtractPlugin({ filename: '../css/app.css' }),
|
|
|
|
new CopyWebpackPlugin([{ from: 'static/', to: '../' }])
|
|
|
|
]
|
|
|
|
});
|