forked from superdesk/newsroom-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
115 lines (111 loc) · 4.37 KB
/
webpack.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* eslint-env node */
const path = require('path');
const webpack = require('webpack');
const ManifestPlugin = require('webpack-manifest-plugin');
const TerserPlugin = require('terser-webpack-plugin-legacy');
const config = {
entry: {
newsroom_js: path.resolve(__dirname, 'assets/index.js'),
companies_js: path.resolve(__dirname, 'assets/companies/index.js'),
oauth_clients_js: path.resolve(__dirname, 'assets/oauth_clients/index.js'),
users_js: path.resolve(__dirname, 'assets/users/index.js'),
products_js: path.resolve(__dirname, 'assets/products/index.js'),
'section-filters_js': path.resolve(__dirname, 'assets/section-filters/index.js'),
navigations_js: path.resolve(__dirname, 'assets/navigations/index.js'),
cards_js: path.resolve(__dirname, 'assets/cards/index.js'),
user_profile_js: path.resolve(__dirname, 'assets/user-profile/index.js'),
newsroom_css: path.resolve(__dirname, 'assets/style.js'),
wire_js: path.resolve(__dirname, 'assets/wire/index.js'),
home_js: path.resolve(__dirname, 'assets/home/index.js'),
agenda_js: path.resolve(__dirname, 'assets/agenda/index.js'),
notifications_js: path.resolve(__dirname, 'assets/notifications/index.js'),
company_reports_js: path.resolve(__dirname, 'assets/company-reports/index.js'),
print_reports_js: path.resolve(__dirname, 'assets/company-reports/components/index.js'),
am_news_js: path.resolve(__dirname, 'assets/am-news/index.js'),
am_news_css: path.resolve(__dirname, 'assets/am-news/style.js'),
'general-settings_js': path.resolve(__dirname, 'assets/general-settings/index.js'),
market_place_js: path.resolve(__dirname, 'assets/market-place/index.js'),
media_releases_js: path.resolve(__dirname, 'assets/media-releases/index.js'),
monitoring_js: path.resolve(__dirname, 'assets/monitoring/index.js'),
factcheck_js: path.resolve(__dirname, 'assets/factcheck/index.js'),
common: path.resolve(__dirname, 'assets/common.js'),
design_js: path.resolve(__dirname, 'assets/design_pages.js'),
company_admin_js: path.resolve(__dirname, 'assets/company-admin/index.js'),
},
output: {
path: path.resolve(process.cwd(), 'dist'),
publicPath: 'http://localhost:8080/',
filename: '[name].[chunkhash].js',
chunkFilename: '[id].[chunkhash].js'
},
module: {
rules: [
{
test: /\.jsx?$/,
include: [
path.resolve(__dirname, 'assets'),
path.resolve(__dirname, 'node_modules/bootstrap'),
path.resolve(process.cwd(), 'node_modules/bootstrap'),
],
loader: 'babel-loader',
options: {
presets: ['es2015', 'react'],
plugins: ['transform-object-rest-spread'],
}
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader',
],
},
{
test: /\.scss$/,
use: [
'style-loader',
'css-loader',
'sass-loader',
],
},
{
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i,
use: [
'file-loader',
],
},
]
},
resolve: {
extensions: ['.js', '.jsx'],
modules: [
path.resolve(__dirname, 'assets'),
'node_modules',
],
alias: {
'moment-timezone': 'moment-timezone/builds/moment-timezone-with-data-10-year-range',
},
mainFields: ['browser', 'main'],
},
plugins: [
new ManifestPlugin({writeToFileEmit: true}),
new webpack.optimize.CommonsChunkPlugin({
name: 'common',
minChunks: Infinity,
}),
],
devServer: {
compress: true,
disableHostCheck: true,
},
};
if (process.env.NODE_ENV === 'production') {
config.plugins.push(new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}));
config.plugins.push(new TerserPlugin({
cache: true,
parallel: true,
}));
}
module.exports = config;