2018-02-26 20:50:13 +01:00
|
|
|
const webpack = require('webpack');
|
2018-09-26 22:14:06 +02:00
|
|
|
const path = require('path');
|
2019-08-28 22:08:40 +02:00
|
|
|
const TerserJSPlugin = require('terser-webpack-plugin');
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
|
|
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
2018-02-26 20:50:13 +01:00
|
|
|
const ManifestPlugin = require('webpack-manifest-plugin');
|
|
|
|
const cssnext = require('postcss-cssnext');
|
|
|
|
const postcssFocus = require('postcss-focus');
|
|
|
|
const postcssReporter = require('postcss-reporter');
|
|
|
|
const cssnano = require('cssnano');
|
2020-07-10 14:45:35 +02:00
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
2018-06-15 22:51:42 +02:00
|
|
|
if (process.env.NODE_ENV === "development") {
|
2018-06-07 23:49:17 +02:00
|
|
|
require('dotenv').config();
|
|
|
|
}
|
2016-06-28 00:46:08 +02:00
|
|
|
|
2018-07-30 18:20:57 +02:00
|
|
|
module.exports = [{
|
2017-05-18 23:41:25 +02:00
|
|
|
devtool: 'source-map',
|
2019-08-28 22:08:40 +02:00
|
|
|
mode: 'production',
|
2016-11-09 00:11:12 +01:00
|
|
|
entry: {
|
|
|
|
app: [
|
2019-06-05 18:05:31 +02:00
|
|
|
'@babel/polyfill',
|
|
|
|
'core-js/modules/es6.promise',
|
|
|
|
'core-js/modules/es6.array.iterator',
|
2018-09-26 22:14:06 +02:00
|
|
|
path.resolve(__dirname, '../client/index.jsx')
|
2016-11-09 00:11:12 +01:00
|
|
|
]
|
|
|
|
},
|
2016-06-28 00:46:08 +02:00
|
|
|
output: {
|
2018-09-26 22:14:06 +02:00
|
|
|
path: path.resolve(__dirname, '../dist/static'),
|
2019-08-28 22:08:40 +02:00
|
|
|
filename: '[name].[hash].js',
|
2018-05-04 22:36:59 +02:00
|
|
|
publicPath: '/'
|
2016-06-28 00:46:08 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
resolve: {
|
2017-11-06 22:19:43 +01:00
|
|
|
extensions: ['.js', '.jsx'],
|
2016-11-09 00:11:12 +01:00
|
|
|
modules: [
|
|
|
|
'client',
|
|
|
|
'node_modules',
|
|
|
|
]
|
2016-06-28 00:46:08 +02:00
|
|
|
},
|
|
|
|
module: {
|
2019-08-28 22:08:40 +02:00
|
|
|
rules: [{
|
2018-07-30 18:20:57 +02:00
|
|
|
test: /main\.scss$/,
|
2016-06-28 00:46:08 +02:00
|
|
|
exclude: /node_modules/,
|
2019-08-28 22:08:40 +02:00
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
|
|
|
options: {
|
|
|
|
importLoaders: 2,
|
|
|
|
sourceMap: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'postcss-loader',
|
|
|
|
options: {
|
|
|
|
plugins: () => [
|
|
|
|
postcssFocus(),
|
|
|
|
cssnext({
|
|
|
|
browsers: ['last 2 versions', 'IE > 9']
|
|
|
|
}),
|
|
|
|
cssnano({
|
|
|
|
autoprefixer: false
|
|
|
|
}),
|
|
|
|
postcssReporter({
|
|
|
|
clearMessages: true
|
|
|
|
})
|
|
|
|
],
|
|
|
|
sourceMap: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'sass-loader',
|
|
|
|
options: {
|
|
|
|
sourceMap: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2016-06-28 00:46:08 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.jsx?$/,
|
|
|
|
exclude: /node_modules/,
|
2018-10-03 03:03:33 +02:00
|
|
|
use: 'babel-loader'
|
2016-06-28 00:46:08 +02:00
|
|
|
},
|
2018-10-03 03:03:33 +02:00
|
|
|
{
|
|
|
|
test: /\.(png)$/,
|
|
|
|
use: {
|
2019-08-28 22:08:40 +02:00
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
name: '[name].[ext]',
|
|
|
|
outputPath: 'images/'
|
|
|
|
}
|
2018-10-03 03:03:33 +02:00
|
|
|
}
|
2016-08-19 19:13:17 +02:00
|
|
|
},
|
|
|
|
{
|
2020-05-06 23:51:09 +02:00
|
|
|
test: /\.mp3$/,
|
|
|
|
use: 'file-loader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /fonts\/.*\.(eot|ttf|woff|woff2)$/,
|
2018-10-03 03:03:33 +02:00
|
|
|
use: 'file-loader'
|
2018-05-15 21:10:24 +02:00
|
|
|
},
|
2020-04-30 00:34:37 +02:00
|
|
|
{
|
|
|
|
test: /\.svg$/,
|
|
|
|
oneOf: [
|
|
|
|
{
|
|
|
|
resourceQuery: /byUrl/,
|
|
|
|
use: 'file-loader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
use: {
|
|
|
|
loader: '@svgr/webpack',
|
|
|
|
options: {
|
|
|
|
svgoConfig: {
|
|
|
|
plugins: {
|
|
|
|
removeViewBox: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2018-05-15 21:10:24 +02:00
|
|
|
{
|
2018-07-30 18:20:57 +02:00
|
|
|
test: /_console-feed.scss/,
|
2018-10-03 03:03:33 +02:00
|
|
|
use: {
|
|
|
|
loader: 'sass-extract-loader',
|
|
|
|
options: {
|
2019-08-28 22:08:40 +02:00
|
|
|
plugins: [{
|
|
|
|
plugin: 'sass-extract-js',
|
|
|
|
options: {
|
|
|
|
camelCase: false
|
|
|
|
}
|
|
|
|
}]
|
2018-10-03 03:03:33 +02:00
|
|
|
}
|
2018-07-30 18:20:57 +02:00
|
|
|
}
|
2016-06-28 00:46:08 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2019-08-28 22:08:40 +02:00
|
|
|
optimization: {
|
|
|
|
minimizer: [new TerserJSPlugin({}), new OptimizeCSSAssetsPlugin({})],
|
|
|
|
},
|
2016-06-28 00:46:08 +02:00
|
|
|
plugins: [
|
2016-11-09 00:11:12 +01:00
|
|
|
new ManifestPlugin({
|
|
|
|
basePath: '/',
|
|
|
|
}),
|
2019-08-28 22:08:40 +02:00
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: 'app.[hash].css',
|
2020-07-10 14:45:35 +02:00
|
|
|
}),
|
|
|
|
new CopyWebpackPlugin({
|
|
|
|
patterns: [
|
|
|
|
{from: path.resolve(__dirname, '../translations/locales') , to: path.resolve(__dirname, '../dist/static/locales')}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
)
|
2019-08-28 22:08:40 +02:00
|
|
|
]
|
2018-07-30 18:20:57 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
entry: {
|
|
|
|
app: [
|
2018-09-26 22:14:06 +02:00
|
|
|
path.resolve(__dirname, '../client/utils/previewEntry.js')
|
2018-07-30 18:20:57 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
target: 'web',
|
2019-08-28 22:08:40 +02:00
|
|
|
mode: 'production',
|
2018-07-30 18:20:57 +02:00
|
|
|
output: {
|
2018-09-26 22:14:06 +02:00
|
|
|
path: path.resolve(__dirname, '../dist/static'),
|
2018-07-30 18:20:57 +02:00
|
|
|
filename: 'previewScripts.js',
|
|
|
|
publicPath: '/'
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: ['*', '.js', '.jsx'],
|
|
|
|
modules: [
|
|
|
|
'client',
|
|
|
|
'node_modules',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
module: {
|
2019-08-28 22:08:40 +02:00
|
|
|
rules: [
|
2018-07-30 18:20:57 +02:00
|
|
|
{
|
|
|
|
test: /\.jsx?$/,
|
|
|
|
exclude: /node_modules/,
|
2019-06-05 18:05:31 +02:00
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
babelrc: true
|
|
|
|
}
|
2018-07-30 18:20:57 +02:00
|
|
|
}
|
|
|
|
]
|
2019-08-28 22:08:40 +02:00
|
|
|
}
|
2018-08-20 18:20:41 +02:00
|
|
|
}];
|