2017-03-31 20:21:41 +02:00
|
|
|
const webpack = require('webpack');
|
2020-08-25 12:22:29 +02:00
|
|
|
const { merge } = require('webpack-merge');
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
2017-03-31 20:21:41 +02:00
|
|
|
const ManifestPlugin = require('webpack-manifest-plugin');
|
2020-08-25 12:22:29 +02:00
|
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
2017-03-31 20:21:41 +02:00
|
|
|
|
|
|
|
const commonConfig = require('./common.js');
|
|
|
|
|
2020-11-11 09:48:04 +01:00
|
|
|
module.exports = merge(commonConfig, {
|
|
|
|
output: {
|
|
|
|
filename: '[name].js',
|
|
|
|
},
|
|
|
|
mode: 'production',
|
|
|
|
devtool: 'source-map',
|
|
|
|
optimization: {
|
|
|
|
minimize: true,
|
|
|
|
minimizer: [
|
|
|
|
new TerserPlugin({
|
|
|
|
parallel: true,
|
|
|
|
terserOptions: {
|
|
|
|
output: {
|
|
|
|
comments: false,
|
2020-08-25 12:22:29 +02:00
|
|
|
},
|
2017-06-20 07:14:04 +02:00
|
|
|
},
|
2020-11-11 09:48:04 +01:00
|
|
|
extractComments: false,
|
2017-06-20 07:14:04 +02:00
|
|
|
}),
|
2017-03-31 20:21:41 +02:00
|
|
|
],
|
2020-11-11 09:48:04 +01:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new MiniCssExtractPlugin(),
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env': {
|
|
|
|
NODE_ENV: JSON.stringify('production'),
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
new ManifestPlugin({
|
|
|
|
fileName: 'manifest.json',
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
enforce: 'pre',
|
|
|
|
test: /\.js$/,
|
|
|
|
loader: 'eslint-loader',
|
|
|
|
exclude: /node_modules/,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /(node_modules)/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
presets: ['@babel/preset-env'],
|
|
|
|
},
|
2017-03-31 20:21:41 +02:00
|
|
|
},
|
2020-11-11 09:48:04 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(sa|sc|c)ss$/,
|
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
2017-03-31 20:21:41 +02:00
|
|
|
options: {
|
2020-11-11 09:48:04 +01:00
|
|
|
importLoaders: 1,
|
2017-06-20 07:14:04 +02:00
|
|
|
},
|
|
|
|
},
|
2020-11-11 09:48:04 +01:00
|
|
|
{
|
|
|
|
loader: 'postcss-loader',
|
2017-03-31 20:21:41 +02:00
|
|
|
options: {
|
2020-11-11 09:48:04 +01:00
|
|
|
postcssOptions: {
|
|
|
|
plugins: ['autoprefixer'],
|
|
|
|
},
|
2017-06-20 07:14:04 +02:00
|
|
|
},
|
|
|
|
},
|
2020-11-11 09:48:04 +01:00
|
|
|
'sass-loader',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(jpg|png|gif|svg|ico)$/,
|
|
|
|
include: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
name: 'img/[name].[ext]',
|
|
|
|
},
|
2017-03-31 20:21:41 +02:00
|
|
|
},
|
2020-11-11 09:48:04 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(jpg|png|gif|svg|ico)$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
context: 'app/Resources/static',
|
|
|
|
name: '[path][name].[ext]',
|
2017-10-15 23:57:35 +02:00
|
|
|
},
|
|
|
|
},
|
2020-11-11 09:48:04 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(eot|ttf|woff|woff2)$/,
|
|
|
|
use: {
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
name: 'fonts/[name].[ext]',
|
2017-06-20 07:14:04 +02:00
|
|
|
},
|
|
|
|
},
|
2020-11-11 09:48:04 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
});
|