2019-03-27 18:10:50 +00:00
|
|
|
const { resolve } = require('path')
|
|
|
|
const webpack = require('webpack')
|
|
|
|
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
|
|
|
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
|
|
|
|
const CompressionPlugin = require('compression-webpack-plugin')
|
|
|
|
const ManifestPlugin = require('webpack-manifest-plugin')
|
2019-09-22 18:01:43 +00:00
|
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
|
2019-03-27 18:10:50 +00:00
|
|
|
|
|
|
|
const browserConfig = {
|
|
|
|
mode: 'production',
|
|
|
|
entry: {
|
|
|
|
bundle: [
|
|
|
|
'./src/app-client.js'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
path: resolve(__dirname, 'public/static'),
|
|
|
|
filename: '[name].[contenthash].js',
|
|
|
|
publicPath: '/static/'
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
use: [
|
|
|
|
'babel-loader'
|
|
|
|
],
|
|
|
|
exclude: '/node_modules/'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.scss$/,
|
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
|
|
|
options: {
|
2019-09-22 18:01:43 +00:00
|
|
|
modules: {
|
|
|
|
localIdentName: '[name]__[local]___[hash:base64:5]'
|
|
|
|
},
|
|
|
|
importLoaders: 2
|
2019-03-27 18:10:50 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'postcss-loader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'sass-loader'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(png|jpg)$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
loader: 'url-loader',
|
|
|
|
options: {
|
|
|
|
limit: 8192
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
minimizer: [
|
|
|
|
new UglifyJsPlugin(),
|
|
|
|
new OptimizeCSSAssetsPlugin({})
|
|
|
|
]
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new ManifestPlugin(),
|
|
|
|
new webpack.DefinePlugin({ __isBrowser__: 'true' }),
|
2019-09-22 18:01:43 +00:00
|
|
|
new CleanWebpackPlugin(),
|
2019-03-27 18:10:50 +00:00
|
|
|
new MiniCssExtractPlugin({ filename: '[name].[contenthash].css' }),
|
|
|
|
new CompressionPlugin({})
|
|
|
|
],
|
|
|
|
node: { fs: 'empty' }
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = browserConfig
|