Rev 5205 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
const path = require('path')
const isDevelopment = process.env.NODE_ENV === 'development'
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const TerserPlugin = require('terser-webpack-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
// Add paths while bundling
const paths = {
dashboard: {
entry: './react-webpack/dashboard/components/index.js',
output: path.join(__dirname, 'public/react-bundles/dashboard'),
filename: 'dashboardBundle.js'
},
notifications: {
entry: './react-webpack/notifications/index.js',
output: path.join(__dirname, 'public/react-bundles/dashboard'),
filename: 'notificationsBundle.js'
},
myProfiles: {
entry: './react-webpack/profile/my-profiles/my-profiles/index.js',
output: path.join(
__dirname,
'public/react-bundles/my-profiles/my-profiles'
),
filename: 'myProfilesBundle.js'
},
peopleViewedProfile: {
entry: './react-webpack/profile/people-viewed-profile/index.js',
output: path.join(
__dirname,
'public/react-bundles/profile/people-viewed-profile'
),
filename: 'peopleViewedProfileBundle.js'
},
profileView: {
entry: './react-webpack/profile/view/index.js',
output: path.join(__dirname, 'public/react-bundles/profile/view'),
filename: 'profileViewBundle.js'
},
profileEdit: {
entry: './react-webpack/profile/my-profiles/edit/index.js',
output: path.join(__dirname, 'public/react-bundles/profile/edit'),
filename: 'profileEditBundle.js'
},
myConnections: {
entry: './react-webpack/connection/my-connections/index.js',
output: path.join(
__dirname,
'public/react-bundles/connection/my-connections'
),
filename: 'myConnectionsBundle.js'
},
invitationsReceived: {
entry: './react-webpack/connection/invitations-received/index.js',
output: path.join(
__dirname,
'public/react-bundles/connection/invitations-received'
),
filename: 'invitationsReceivedBundle.js'
},
invitationsSent: {
entry: './react-webpack/connection/invitations-sent/index.js',
output: path.join(
__dirname,
'public/react-bundles/connection/invitations-sent'
),
filename: 'invitationsSentBundle.js'
},
peopleYouMayKnow: {
entry: './react-webpack/connection/people-you-may-know/index.js',
output: path.join(
__dirname,
'public/react-bundles/connection/people-you-may-know'
),
filename: 'peopleYouMayKnowBundle.js'
},
peopleBlocked: {
entry: './react-webpack/connection/people-blocked/index.js',
output: path.join(
__dirname,
'public/react-bundles/connection/people-blocked'
),
filename: 'peopleBlockedBundle.js'
},
myCompanies: {
entry: './react-webpack/company/my-companies/index.js',
output: path.join(__dirname, 'public/react-bundles/my-companies'),
filename: 'myCompaniesBundle.js'
},
followingCompanies: {
entry: './react-webpack/company/following-companies/index.js',
output: path.join(__dirname, 'public/react-bundles/following-companies'),
filename: 'followingCompaniesBundle.js'
},
companiesIWorkWith: {
entry: './react-webpack/company/i-work-with/index.js',
output: path.join(__dirname, 'public/react-bundles/company/i-work-with'),
filename: 'iWorkWithBundle.js'
},
companiesRequestSent: {
entry: './react-webpack/company/request-sent/index.js',
output: path.join(__dirname, 'public/react-bundles/company/request-sent'),
filename: 'requestSentBundle.js'
},
companiesInvitationsReceived: {
entry: './react-webpack/company/invitations-received/index.js',
output: path.join(
__dirname,
'public/react-bundles/company/invitations-received'
),
filename: 'invitationsReceivedBundle.js'
},
companyView: {
entry: './react-webpack/company/view/index.js',
output: path.join(__dirname, 'public/react-bundles/company/view'),
filename: 'companyViewBundle.js'
},
appliedJobs: {
entry: './react-webpack/job/applied-jobs/index.js',
output: path.join(__dirname, 'public/react-bundles/job/applied-jobs'),
filename: 'appliedJobsBundle.js'
},
savedJobs: {
entry: './react-webpack/job/saved-jobs/index.js',
output: path.join(__dirname, 'public/react-bundles/job/saved-jobs'),
filename: 'savedJobsBundle.js'
},
jobView: {
entry: './react-webpack/job/view/index.js',
output: path.join(__dirname, 'public/react-bundles/job/view'),
filename: 'jobViewBundle.js'
},
authSignin: {
entry: './react-webpack/auth/signin-section/index.js',
output: path.join(__dirname, 'public/react-bundles/auth/signin'),
filename: 'signinBundle.js'
},
myGroups: {
entry: './react-webpack/group/my-groups/my-groups/index.js',
output: path.join(__dirname, 'public/react-bundles/my-groups'),
filename: 'myGroupsBundle.js'
},
groupEdit: {
entry: './react-webpack/group/my-groups/edit/index.js',
output: path.join(__dirname, 'public/react-bundles/groupEdit'),
filename: 'groupEdit.js'
},
groupView: {
entry: './react-webpack/group/view/index.js',
output: path.join(__dirname, 'public/react-bundles/group/groupView'),
filename: 'groupView.js'
},
joinedGroups: {
entry: './react-webpack/group/joined-groups/index.js',
output: path.join(__dirname, 'public/react-bundles/group/joined-groups'),
filename: 'joinedGroupsBundle.js'
},
groupRequestsSent: {
entry: './react-webpack/group/requests-sent/index.js',
output: path.join(__dirname, 'public/react-bundles/group/requests-sent'),
filename: 'requestSentBundle.js'
},
groupInvitationsReceived: {
entry: './react-webpack/group/invitations-received/index.js',
output: path.join(
__dirname,
'public/react-bundles/group/invitations-received'
),
filename: 'invitationsReceivedBundle.js'
},
accountSettings: {
entry: './react-webpack/account-settings/index.js',
output: path.join(__dirname, 'public/react-bundles/account-settings'),
filename: 'accountSettingsBundle.js'
},
navBar: {
entry: './react-webpack/navbar/index.js',
output: path.join(__dirname, 'public/react-bundles/navbar'),
filename: 'navbarBundle.js'
},
chat: {
entry: './react-webpack/chat/index.js',
output: path.join(__dirname, 'public/react-bundles/chat'),
filename: 'chatBundle.js'
},
mobileChat: {
entry: './react-webpack/mobile-chat/index.js',
output: path.join(__dirname, 'public/react-bundles/mobileChat'),
filename: 'mobileChatBundle.js'
},
inmail: {
entry: './react-webpack/inmail/index.js',
output: path.join(__dirname, 'public/react-bundles/inmail'),
filename: 'inmailBundle.js'
},
marketplace: {
entry: './react-webpack/marketplace/index.js',
output: path.join(__dirname, 'public/react-bundles/marketplace'),
filename: 'marketplaceBundle.js'
},
profileMicrolearning: {
entry: './react-webpack/profile-microlearning/index.js',
output: path.join(__dirname, 'public/react-bundles/profile-microlearning'),
filename: 'profileMicrolearningBundle.js'
},
resetPassword: {
entry: './react-webpack/auth/signin-section/signin-section/reset-password/index.js',
output: path.join(__dirname, 'public/react-bundles/auth/reset-password'),
filename: 'resetPasswordBundle.js'
},
search: {
entry: './react-webpack/search/index.js',
output: path.join(__dirname, 'public/react-bundles/search'),
filename: 'searchBundle.js'
},
postView: {
entry: './react-webpack/dashboard/post/index.js',
output: path.join(__dirname, 'public/react-bundles/postView'),
filename: 'postViewBundle.js'
},
selfEvaluation: {
entry: './react-webpack/self-evaluation/index.js',
output: path.join(__dirname, 'public/react-bundles/self-evaluation'),
filename: 'selfEvaluationBundle.js'
},
performanceEvaluation: {
entry: './react-webpack/performance-evaluation/index.js',
output: path.join(__dirname, 'public/react-bundles/performance-evaluation'),
filename: 'performanceEvaluationBundle.js'
},
impersonate: {
entry: './react-webpack/impersonate/index.js',
output: path.join(__dirname, 'public/react-bundles/impersonate'),
filename: 'impersonateBundle.js'
}
}
// change active path here
const currentPath = paths.marketplace;
module.exports = {
entry: currentPath.entry,
output: {
path: currentPath.output,
filename: currentPath.filename
},
watch: !!isDevelopment,
mode: isDevelopment ? 'development' : 'production',
resolve: {
extensions: ['.js', '.jsx', '.scss']
},
module: {
rules: [
{
test: /(js|jsx)$/,
use: ['babel-loader'],
exclude: /node_modules/
},
{
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader']
},
{
test: /\.module\.s(a|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
modules: {
localIdentName: '[local]--[hash:base64:5]'
},
sourceMap: isDevelopment
}
},
{
loader: 'sass-loader',
options: {
sourceMap: isDevelopment
}
}
]
},
{
test: /\.s(a|c)ss$/,
exclude: /\.module.(s(a|c)ss)$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'sass-loader',
options: {
sourceMap: isDevelopment
}
}
]
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css'
})
],
optimization: {
minimizer: [
new TerserPlugin({
extractComments: false
})
]
}
/*
plugins: [
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css",
}),
new BundleAnalyzerPlugin({analyzerMode: 'server'})
],
optimization: {
minimizer: [
new TerserPlugin({
extractComments: false,
}),
],
}, */
}