-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.serverSide.config.js
64 lines (62 loc) · 1.84 KB
/
webpack.serverSide.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const webpack = require('webpack');
const path = require('path');
const globImporter = require('node-sass-glob-importer');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const SassLintPlugin = require('sass-lint-webpack');
const postcssPresetEnv = require('postcss-preset-env');
module.exports = (env, argv) => ({
optimization: {
minimize: true,
minimizer: [new TerserPlugin({
test: /\.js/,
terserOptions: {
sourceMaps: argv.mode === 'development',
compress: {
drop_console: argv.mode !== 'development'
}
}
})]
},
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(argv.mode === 'development' ? 'development' : 'production'),
'process.env.BABEL_ENV': JSON.stringify(argv.mode === 'development' ? 'development' : 'production'),
'process.env.SERVER_SIDE': JSON.stringify(argv.mode === 'development' ? 'development' : 'production')
}),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
],
entry: {
'bloc.serverSide' : ['./assets/js/src/serverSideReact/index.jsx']
},
output: {
path: path.join(__dirname, 'assets', 'dist'),
filename: '[name].min.js',
publicPath: '/assets/dist'
},
module: {
rules: [
{
test: /\.(jsx?)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
envName: 'production'
}
},
resolve: {
extensions: ['.js', '.jsx']
}
},
{
enforce: 'pre',
test: /\.jsx?$/,
exclude: /node_modules|.*vendor.*/,
loader: 'eslint-loader'
}
]
}
});