8054a532d7
* remove some of the react errors, start to fix webpack HMR errors * start upgrade to webpack 4 * more stuff to update webpack * update webpack configs to work with webpack 4 * remove linting from truncate script
161 lines
3.5 KiB
JavaScript
161 lines
3.5 KiB
JavaScript
const webpack = require('webpack');
|
|
const path = require('path');
|
|
const TerserJSPlugin = require('terser-webpack-plugin');
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
|
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');
|
|
if (process.env.NODE_ENV === "development") {
|
|
require('dotenv').config();
|
|
}
|
|
|
|
module.exports = [{
|
|
devtool: 'source-map',
|
|
mode: 'production',
|
|
entry: {
|
|
app: [
|
|
'@babel/polyfill',
|
|
'core-js/modules/es6.promise',
|
|
'core-js/modules/es6.array.iterator',
|
|
path.resolve(__dirname, '../client/index.jsx')
|
|
]
|
|
},
|
|
output: {
|
|
path: path.resolve(__dirname, '../dist/static'),
|
|
filename: '[name].[hash].js',
|
|
publicPath: '/'
|
|
},
|
|
|
|
resolve: {
|
|
extensions: ['.js', '.jsx'],
|
|
modules: [
|
|
'client',
|
|
'node_modules',
|
|
]
|
|
},
|
|
module: {
|
|
rules: [{
|
|
test: /main\.scss$/,
|
|
exclude: /node_modules/,
|
|
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
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
test: /\.jsx?$/,
|
|
exclude: /node_modules/,
|
|
use: 'babel-loader'
|
|
},
|
|
{
|
|
test: /\.(svg|mp3)$/,
|
|
use: 'file-loader'
|
|
},
|
|
{
|
|
test: /\.(png)$/,
|
|
use: {
|
|
loader: 'file-loader',
|
|
options: {
|
|
name: '[name].[ext]',
|
|
outputPath: 'images/'
|
|
}
|
|
}
|
|
},
|
|
{
|
|
test: /fonts\/.*\.(eot|svg|ttf|woff|woff2)$/,
|
|
use: 'file-loader'
|
|
},
|
|
{
|
|
test: /_console-feed.scss/,
|
|
use: {
|
|
loader: 'sass-extract-loader',
|
|
options: {
|
|
plugins: [{
|
|
plugin: 'sass-extract-js',
|
|
options: {
|
|
camelCase: false
|
|
}
|
|
}]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
optimization: {
|
|
minimizer: [new TerserJSPlugin({}), new OptimizeCSSAssetsPlugin({})],
|
|
},
|
|
plugins: [
|
|
new ManifestPlugin({
|
|
basePath: '/',
|
|
}),
|
|
new MiniCssExtractPlugin({
|
|
filename: 'app.[hash].css',
|
|
})
|
|
]
|
|
},
|
|
{
|
|
entry: {
|
|
app: [
|
|
path.resolve(__dirname, '../client/utils/previewEntry.js')
|
|
]
|
|
},
|
|
target: 'web',
|
|
mode: 'production',
|
|
output: {
|
|
path: path.resolve(__dirname, '../dist/static'),
|
|
filename: 'previewScripts.js',
|
|
publicPath: '/'
|
|
},
|
|
resolve: {
|
|
extensions: ['*', '.js', '.jsx'],
|
|
modules: [
|
|
'client',
|
|
'node_modules',
|
|
],
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.jsx?$/,
|
|
exclude: /node_modules/,
|
|
loader: 'babel-loader',
|
|
options: {
|
|
babelrc: true
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}];
|