2018-02-26 19:50:13 +00:00
|
|
|
const webpack = require('webpack');
|
2018-09-26 20:14:06 +00:00
|
|
|
const path = require('path');
|
2019-08-28 20:08:40 +00: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 19:50:13 +00: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');
|
2018-06-15 20:51:42 +00:00
|
|
|
if (process.env.NODE_ENV === "development") {
|
2018-06-07 21:49:17 +00:00
|
|
|
require('dotenv').config();
|
|
|
|
}
|
2016-06-27 22:46:08 +00:00
|
|
|
|
2018-07-30 16:20:57 +00:00
|
|
|
module.exports = [{
|
2017-05-18 21:41:25 +00:00
|
|
|
devtool: 'source-map',
|
2019-08-28 20:08:40 +00:00
|
|
|
mode: 'production',
|
2016-11-08 23:11:12 +00:00
|
|
|
entry: {
|
|
|
|
app: [
|
2019-06-05 16:05:31 +00:00
|
|
|
'@babel/polyfill',
|
|
|
|
'core-js/modules/es6.promise',
|
|
|
|
'core-js/modules/es6.array.iterator',
|
2018-09-26 20:14:06 +00:00
|
|
|
path.resolve(__dirname, '../client/index.jsx')
|
2016-11-08 23:11:12 +00:00
|
|
|
]
|
|
|
|
},
|
2016-06-27 22:46:08 +00:00
|
|
|
output: {
|
2018-09-26 20:14:06 +00:00
|
|
|
path: path.resolve(__dirname, '../dist/static'),
|
2019-08-28 20:08:40 +00:00
|
|
|
filename: '[name].[hash].js',
|
2018-05-04 20:36:59 +00:00
|
|
|
publicPath: '/'
|
2016-06-27 22:46:08 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
resolve: {
|
2017-11-06 21:19:43 +00:00
|
|
|
extensions: ['.js', '.jsx'],
|
2016-11-08 23:11:12 +00:00
|
|
|
modules: [
|
|
|
|
'client',
|
|
|
|
'node_modules',
|
|
|
|
]
|
2016-06-27 22:46:08 +00:00
|
|
|
},
|
|
|
|
module: {
|
2019-08-28 20:08:40 +00:00
|
|
|
rules: [{
|
2018-07-30 16:20:57 +00:00
|
|
|
test: /main\.scss$/,
|
2016-06-27 22:46:08 +00:00
|
|
|
exclude: /node_modules/,
|
2019-08-28 20:08:40 +00: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-27 22:46:08 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.jsx?$/,
|
|
|
|
exclude: /node_modules/,
|
2018-10-03 01:03:33 +00:00
|
|
|
use: 'babel-loader'
|
2016-06-27 22:46:08 +00:00
|
|
|
},
|
|
|
|
{
|
2016-08-15 15:51:11 +00:00
|
|
|
test: /\.(svg|mp3)$/,
|
2018-10-03 01:03:33 +00:00
|
|
|
use: 'file-loader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(png)$/,
|
|
|
|
use: {
|
2019-08-28 20:08:40 +00:00
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
name: '[name].[ext]',
|
|
|
|
outputPath: 'images/'
|
|
|
|
}
|
2018-10-03 01:03:33 +00:00
|
|
|
}
|
2016-08-19 17:13:17 +00:00
|
|
|
},
|
|
|
|
{
|
2018-02-26 19:50:13 +00:00
|
|
|
test: /fonts\/.*\.(eot|svg|ttf|woff|woff2)$/,
|
2018-10-03 01:03:33 +00:00
|
|
|
use: 'file-loader'
|
2018-05-15 19:10:24 +00:00
|
|
|
},
|
|
|
|
{
|
2018-07-30 16:20:57 +00:00
|
|
|
test: /_console-feed.scss/,
|
2018-10-03 01:03:33 +00:00
|
|
|
use: {
|
|
|
|
loader: 'sass-extract-loader',
|
|
|
|
options: {
|
2019-08-28 20:08:40 +00:00
|
|
|
plugins: [{
|
|
|
|
plugin: 'sass-extract-js',
|
|
|
|
options: {
|
|
|
|
camelCase: false
|
|
|
|
}
|
|
|
|
}]
|
2018-10-03 01:03:33 +00:00
|
|
|
}
|
2018-07-30 16:20:57 +00:00
|
|
|
}
|
2016-06-27 22:46:08 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2019-08-28 20:08:40 +00:00
|
|
|
optimization: {
|
|
|
|
minimizer: [new TerserJSPlugin({}), new OptimizeCSSAssetsPlugin({})],
|
|
|
|
},
|
2016-06-27 22:46:08 +00:00
|
|
|
plugins: [
|
2016-11-08 23:11:12 +00:00
|
|
|
new ManifestPlugin({
|
|
|
|
basePath: '/',
|
|
|
|
}),
|
2019-08-28 20:08:40 +00:00
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: 'app.[hash].css',
|
2016-07-22 22:56:54 +00:00
|
|
|
})
|
2019-08-28 20:08:40 +00:00
|
|
|
]
|
2018-07-30 16:20:57 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
entry: {
|
|
|
|
app: [
|
2018-09-26 20:14:06 +00:00
|
|
|
path.resolve(__dirname, '../client/utils/previewEntry.js')
|
2018-07-30 16:20:57 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
target: 'web',
|
2019-08-28 20:08:40 +00:00
|
|
|
mode: 'production',
|
2018-07-30 16:20:57 +00:00
|
|
|
output: {
|
2018-09-26 20:14:06 +00:00
|
|
|
path: path.resolve(__dirname, '../dist/static'),
|
2018-07-30 16:20:57 +00:00
|
|
|
filename: 'previewScripts.js',
|
|
|
|
publicPath: '/'
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: ['*', '.js', '.jsx'],
|
|
|
|
modules: [
|
|
|
|
'client',
|
|
|
|
'node_modules',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
module: {
|
2019-08-28 20:08:40 +00:00
|
|
|
rules: [
|
2018-07-30 16:20:57 +00:00
|
|
|
{
|
|
|
|
test: /\.jsx?$/,
|
|
|
|
exclude: /node_modules/,
|
2019-06-05 16:05:31 +00:00
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
babelrc: true
|
|
|
|
}
|
2018-07-30 16:20:57 +00:00
|
|
|
}
|
|
|
|
]
|
2019-08-28 20:08:40 +00:00
|
|
|
}
|
2018-08-20 16:20:41 +00:00
|
|
|
}];
|