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');
|
2017-03-31 18:21:41 +00:00
|
|
|
const ManifestPlugin = 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');
|
|
|
|
|
2017-06-20 05:14:04 +00:00
|
|
|
module.exports = function () {
|
2020-08-25 10:22:29 +00:00
|
|
|
return merge(commonConfig(), {
|
2017-03-31 18:21:41 +00:00
|
|
|
output: {
|
2017-06-20 05:14:04 +00:00
|
|
|
filename: '[name].js',
|
2017-03-31 18:21:41 +00:00
|
|
|
},
|
2020-08-25 10:22:29 +00:00
|
|
|
mode: 'production',
|
2017-03-31 18:21:41 +00:00
|
|
|
devtool: 'source-map',
|
2020-08-25 10:22:29 +00:00
|
|
|
optimization: {
|
|
|
|
minimizer: [
|
|
|
|
new TerserPlugin({
|
|
|
|
cache: true,
|
|
|
|
parallel: true,
|
|
|
|
sourceMap: true,
|
|
|
|
terserOptions: {
|
|
|
|
output: {
|
|
|
|
comments: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
extractComments: false,
|
|
|
|
}),
|
|
|
|
]
|
|
|
|
},
|
2017-03-31 18:21:41 +00:00
|
|
|
plugins: [
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env': {
|
2017-06-20 05:14:04 +00:00
|
|
|
'NODE_ENV': JSON.stringify('production'),
|
|
|
|
},
|
2017-03-31 18:21:41 +00:00
|
|
|
}),
|
2020-08-25 10:22:29 +00:00
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: '[name].css',
|
|
|
|
chunkFilename: '[id].css',
|
2017-03-31 18:21:41 +00:00
|
|
|
}),
|
|
|
|
new ManifestPlugin({
|
|
|
|
fileName: 'manifest.json',
|
2017-06-20 05:14:04 +00:00
|
|
|
}),
|
2017-03-31 18:21:41 +00:00
|
|
|
],
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
enforce: 'pre',
|
|
|
|
test: /\.js$/,
|
|
|
|
loader: 'eslint-loader',
|
|
|
|
exclude: /node_modules/,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /(node_modules)/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
2020-08-25 10:22:29 +00:00
|
|
|
presets: ['@babel/preset-env']
|
2017-06-20 05:14:04 +00:00
|
|
|
},
|
|
|
|
},
|
2017-03-31 18:21:41 +00:00
|
|
|
},
|
|
|
|
{
|
2020-08-25 10:22:29 +00:00
|
|
|
test: /\.(sa|sc|c)ss$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: MiniCssExtractPlugin.loader,
|
|
|
|
options: {
|
|
|
|
hmr: process.env.NODE_ENV === 'development',
|
2017-03-31 18:21:41 +00:00
|
|
|
},
|
2020-08-25 10:22:29 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
|
|
|
options: {
|
|
|
|
importLoaders: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'postcss-loader',
|
|
|
|
options: {
|
|
|
|
plugins: [require('autoprefixer')({})],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'sass-loader',
|
|
|
|
],
|
2017-03-31 18:21:41 +00:00
|
|
|
},
|
|
|
|
{
|
2017-10-15 21:57:35 +00:00
|
|
|
test: /\.(jpg|png|gif|svg|ico)$/,
|
|
|
|
include: /node_modules/,
|
2017-03-31 18:21:41 +00:00
|
|
|
use: {
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
name: 'img/[name].[ext]',
|
2017-06-20 05:14:04 +00:00
|
|
|
},
|
|
|
|
},
|
2017-03-31 18:21:41 +00:00
|
|
|
},
|
2017-10-15 21:57:35 +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-03-31 18:21:41 +00:00
|
|
|
{
|
|
|
|
test: /\.(eot|ttf|woff|woff2)$/,
|
|
|
|
use: {
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
name: 'fonts/[name].[ext]',
|
2017-06-20 05:14:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2017-03-31 18:21:41 +00:00
|
|
|
},
|
2017-06-20 05:14:04 +00:00
|
|
|
});
|
2017-03-31 18:21:41 +00:00
|
|
|
};
|