analytics/assets/webpack.config.js

50 lines
1.4 KiB
JavaScript
Raw Normal View History

2019-09-02 14:29:19 +03:00
const path = require('path');
const glob = require('glob');
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');
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(),
new CssMinimizerWebpackPlugin()
2019-09-02 14:29:19 +03:00
]
},
entry: {
'app': ['./js/app.js'],
'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: [
{
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']
}
]
},
externals: { moment: 'moment' },
2019-09-02 14:29:19 +03:00
plugins: [
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
]
});