2017-03-31 18:21:41 +00:00
|
|
|
const webpack = require('webpack');
|
2020-08-25 10:22:29 +00:00
|
|
|
const { merge } = require('webpack-merge');
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
2020-12-03 09:15:21 +00:00
|
|
|
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
|
2020-08-25 10:22:29 +00:00
|
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
2017-03-31 18:21:41 +00:00
|
|
|
|
|
|
|
const commonConfig = require('./common.js');
|
|
|
|
|
2020-11-11 08:48:04 +00: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 10:22:29 +00:00
|
|
|
},
|
2017-06-20 05:14:04 +00:00
|
|
|
},
|
2020-11-11 08:48:04 +00:00
|
|
|
extractComments: false,
|
2017-06-20 05:14:04 +00:00
|
|
|
}),
|
2017-03-31 18:21:41 +00:00
|
|
|
],
|
2020-11-11 08:48:04 +00:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new MiniCssExtractPlugin(),
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env': {
|
|
|
|
NODE_ENV: JSON.stringify('production'),
|
|
|
|
},
|
|
|
|
}),
|
2020-12-03 09:15:21 +00:00
|
|
|
new WebpackManifestPlugin({
|
2020-11-11 08:48:04 +00:00
|
|
|
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 18:21:41 +00:00
|
|
|
},
|
2020-11-11 08:48:04 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(sa|sc|c)ss$/,
|
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
2017-03-31 18:21:41 +00:00
|
|
|
options: {
|
2020-11-11 08:48:04 +00:00
|
|
|
importLoaders: 1,
|
2017-06-20 05:14:04 +00:00
|
|
|
},
|
|
|
|
},
|
2020-11-11 08:48:04 +00:00
|
|
|
{
|
|
|
|
loader: 'postcss-loader',
|
2017-03-31 18:21:41 +00:00
|
|
|
options: {
|
2020-11-11 08:48:04 +00:00
|
|
|
postcssOptions: {
|
|
|
|
plugins: ['autoprefixer'],
|
|
|
|
},
|
2017-06-20 05:14:04 +00:00
|
|
|
},
|
|
|
|
},
|
2020-11-11 08:48:04 +00:00
|
|
|
'sass-loader',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(jpg|png|gif|svg|ico)$/,
|
|
|
|
include: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
name: 'img/[name].[ext]',
|
|
|
|
},
|
2017-03-31 18:21:41 +00:00
|
|
|
},
|
2020-11-11 08:48:04 +00: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 21:57:35 +00:00
|
|
|
},
|
|
|
|
},
|
2020-11-11 08:48:04 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(eot|ttf|woff|woff2)$/,
|
|
|
|
use: {
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
name: 'fonts/[name].[ext]',
|
2017-06-20 05:14:04 +00:00
|
|
|
},
|
|
|
|
},
|
2020-11-11 08:48:04 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
});
|