Skip to content

Instantly share code, notes, and snippets.

@4knort
Created February 27, 2019 20:19
Show Gist options
  • Save 4knort/c3578e1eb7c142d9a4a643bdc0704b99 to your computer and use it in GitHub Desktop.
Save 4knort/c3578e1eb7c142d9a4a643bdc0704b99 to your computer and use it in GitHub Desktop.
const commonConfig = require('./common');
const merge = require('webpack-merge');
const webpack = require('webpack');
const path = require('path');
const SentryCliPlugin = require('@sentry/webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ReactSSRClientPlugin = require('react-server-renderer/client-plugin');
const babelLoader = require('./babel.loader');
const scssLoaders = require('./scss.loader');
const chartingLibraryCustomCssLoaders = require('./charting-library-custom-css.loader');
const distPath = path.resolve(__dirname, '../dist/browser');
module.exports = merge(commonConfig, {
mode: 'production',
entry: { main: [path.resolve(__dirname, '../src/client.tsx')] },
devtool: 'source-map',
output: {
path: distPath,
filename: '[name]-[hash].js',
publicPath: '/dist/',
chunkFilename: '[name]-[hash].bundle.js'
},
module: {
rules: [
babelLoader(false),
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader
},
'css-loader'
]
},
{
test: /\.scss$/,
oneOf: [
{
resourceQuery: /charting-library/,
use: chartingLibraryCustomCssLoaders
},
{
use: [
{
loader: MiniCssExtractPlugin.loader
},
...scssLoaders
]
}
]
}
]
},
plugins: [
new ReactSSRClientPlugin({
filename: 'react-ssr-client-manifest.json'
}),
new SentryCliPlugin({
include: './dist/browser',
ignoreFile: '.sentrycliignore',
ignore: ['node_modules', 'prod.browser.js'],
configFile: 'sentry.properties'
}),
new CleanWebpackPlugin([distPath], { root: path.resolve('.') }),
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../locales'),
to: path.join(distPath, 'locales'),
ignore: ['*.js']
},
{
from: path.resolve(__dirname, '../src/static/apple-app-site-association'),
to: path.join(distPath)
},
{
from: path.resolve(
__dirname,
'../../../node_modules/@unitedtraders/charting-library/static'
),
to: path.join(distPath, 'charting-library/static')
},
{
from: path.resolve(__dirname, '../redirectPage'),
to: path.join(distPath, 'redirect')
}
]),
new webpack.DefinePlugin({
SSR: false
}),
new MiniCssExtractPlugin()
]
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment