2019-09-02 14:29:19 +03:00
|
|
|
const path = require('path');
|
2021-07-05 15:16:56 +03:00
|
|
|
const webpack = require('webpack');
|
2019-09-02 14:29:19 +03:00
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
2020-11-17 15:01:49 +03:00
|
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
2021-06-07 12:12:02 +03:00
|
|
|
const CssMinimizerWebpackPlugin = require('css-minimizer-webpack-plugin');
|
2019-09-02 14:29:19 +03:00
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
|
|
|
|
|
|
module.exports = (env, options) => ({
|
|
|
|
optimization: {
|
|
|
|
minimizer: [
|
2020-11-17 15:01:49 +03:00
|
|
|
new TerserPlugin(),
|
2021-06-07 12:12:02 +03:00
|
|
|
new CssMinimizerWebpackPlugin()
|
2019-09-02 14:29:19 +03:00
|
|
|
]
|
|
|
|
},
|
|
|
|
entry: {
|
|
|
|
'app': ['./js/app.js'],
|
2021-03-15 16:56:12 +03:00
|
|
|
'dashboard': ['./js/dashboard/mount.js'],
|
|
|
|
'embed.host': ['./js/embed.host.js'],
|
|
|
|
'embed.content': ['./js/embed.content.js']
|
2019-09-02 14:29:19 +03:00
|
|
|
},
|
|
|
|
output: {
|
|
|
|
filename: '[name].js',
|
|
|
|
path: path.resolve(__dirname, '../priv/static/js')
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
2019-11-19 07:30:42 +03:00
|
|
|
test: /\.(js|jsx)$/,
|
2019-09-02 14:29:19 +03:00
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader']
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2020-03-04 18:24:18 +03:00
|
|
|
externals: { moment: 'moment' },
|
2019-09-02 14:29:19 +03:00
|
|
|
plugins: [
|
2020-03-04 18:24:18 +03:00
|
|
|
new MiniCssExtractPlugin({filename: '../css/[name].css'}),
|
2020-08-17 16:16:14 +03:00
|
|
|
new CopyWebpackPlugin({patterns: [{from: 'static/', to: '../' }]}),
|
2021-07-05 15:16:56 +03:00
|
|
|
new webpack.ProvidePlugin({
|
|
|
|
ResizeObserver: ['@juggle/resize-observer', 'ResizeObserver'] // https://caniuse.com/?search=ResizeObserver
|
|
|
|
})
|
2019-09-02 14:29:19 +03:00
|
|
|
]
|
|
|
|
});
|