DocSpace-client/web/ASC.Web.Login/webpack.config.js

206 lines
5.1 KiB
JavaScript
Raw Normal View History

2021-12-21 07:59:11 +00:00
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ModuleFederationPlugin = require('webpack').container.ModuleFederationPlugin;
const ExternalTemplateRemotesPlugin = require('external-remotes-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const combineUrl = require('@appserver/common/utils/combineUrl');
const AppServerConfig = require('@appserver/common/constants/AppServerConfig');
const sharedDeps = require('@appserver/common/constants/sharedDependencies');
2021-03-22 14:35:33 +00:00
const { proxyURL } = AppServerConfig;
2021-03-10 16:24:15 +00:00
2021-12-21 07:59:11 +00:00
const path = require('path');
const pkg = require('./package.json');
const deps = pkg.dependencies || {};
2021-03-22 14:35:33 +00:00
const homepage = pkg.homepage; // combineUrl(proxyURL, pkg.homepage);
2021-03-10 16:24:15 +00:00
const title = pkg.title;
var config = {
2021-12-21 07:59:11 +00:00
entry: './src/index',
target: 'web',
mode: 'development',
devServer: {
devMiddleware: {
publicPath: homepage,
},
static: {
2021-12-21 07:59:11 +00:00
directory: path.join(__dirname, 'dist'),
publicPath: homepage,
},
Merge branch 'develop' into feature/workspaces # Conflicts: # packages/asc-web-common/src/components/GroupSelector/GroupSelector.stories.js # packages/asc-web-common/src/components/NavMenu/sub-components/header-nav.js # packages/asc-web-common/src/components/NavMenu/sub-components/header.js # packages/asc-web-common/src/components/NavMenu/sub-components/nav-item.js # packages/asc-web-common/src/components/NavMenu/sub-components/nav-logo-item.js # packages/asc-web-common/src/components/PageLayout/index.js # packages/asc-web-common/src/components/PeopleSelector/PeopleSelector.stories.js # packages/asc-web-common/src/components/PrivateRoute/PrivateRoute.js # packages/asc-web-common/src/store/AuthStore.js # packages/asc-web-common/src/store/ModuleStore.js # packages/asc-web-common/src/store/SettingsStore.js # packages/asc-web-common/src/store/UserStore.js # packages/asc-web-common/src/store/auth/actions.js # packages/asc-web-common/src/store/auth/index.js # packages/asc-web-common/src/store/auth/reducer.js # packages/asc-web-common/src/store/auth/selectors.js # products/ASC.Files/Client/config-overrides.js # products/ASC.Files/Client/package.json # products/ASC.Files/Client/src/App.js # products/ASC.Files/Client/src/components/Article/Body/ThirdPartyList.js # products/ASC.Files/Client/src/components/Article/Body/TreeFolders.js # products/ASC.Files/Client/src/components/Article/Body/TreeSettings.js # products/ASC.Files/Client/src/components/Article/Body/index.js # products/ASC.Files/Client/src/components/Article/Header/index.js # products/ASC.Files/Client/src/components/Article/MainButton/index.js # products/ASC.Files/Client/src/components/dialogs/ConnectDialog/index.js # products/ASC.Files/Client/src/components/dialogs/ConvertDialog/index.js # products/ASC.Files/Client/src/components/dialogs/DeleteDialog/index.js # products/ASC.Files/Client/src/components/dialogs/DeleteThirdPartyDialog/index.js # products/ASC.Files/Client/src/components/dialogs/DownloadDialog/index.js # products/ASC.Files/Client/src/components/dialogs/EmptyTrashDialog/index.js # products/ASC.Files/Client/src/components/dialogs/ThirdPartyMoveDialog/index.js # products/ASC.Files/Client/src/components/pages/Home/Section/Body/BadgesFileTile.js # products/ASC.Files/Client/src/components/pages/Home/Section/Body/FilesRowContent.js # products/ASC.Files/Client/src/components/pages/Home/Section/Body/FilesTileContent.js # products/ASC.Files/Client/src/components/pages/Home/Section/Body/index.js # products/ASC.Files/Client/src/components/pages/Home/Section/Filter/index.js # products/ASC.Files/Client/src/components/pages/Home/Section/Header/index.js # products/ASC.Files/Client/src/components/pages/Home/Section/Paging/index.js # products/ASC.Files/Client/src/components/pages/Home/index.js # products/ASC.Files/Client/src/components/pages/Settings/Section/Body/ConnectedClouds.js # products/ASC.Files/Client/src/components/pages/Settings/Section/Body/index.js # products/ASC.Files/Client/src/components/pages/VersionHistory/Section/Body/VersionRow.js # products/ASC.Files/Client/src/components/pages/VersionHistory/Section/Body/index.js # products/ASC.Files/Client/src/components/pages/VersionHistory/index.js # products/ASC.Files/Client/src/components/panels/AddGroupsPanel/index.js # products/ASC.Files/Client/src/components/panels/AddUsersPanel/index.js # products/ASC.Files/Client/src/components/panels/ChangeOwnerPanel/index.js # products/ASC.Files/Client/src/components/panels/EmbeddingPanel/index.js # products/ASC.Files/Client/src/components/panels/NewFilesPanel/index.js # products/ASC.Files/Client/src/components/panels/OperationsPanel/index.js # products/ASC.Files/Client/src/components/panels/SharingPanel/AccessComboBox.js # products/ASC.Files/Client/src/components/panels/SharingPanel/SharingRow.js # products/ASC.Files/Client/src/components/panels/SharingPanel/index.js # products/ASC.Files/Client/src/components/panels/UploadPanel/ShareButton.js # products/ASC.Files/Client/src/components/panels/UploadPanel/index.js # products/ASC.Files/Client/src/components/panels/VersionHistoryPanel/index.js # products/ASC.Files/Client/src/helpers/desktop.js # products/ASC.Files/Client/src/helpers/i18n.js # products/ASC.Files/Client/src/helpers/utils.js # products/ASC.Files/Client/src/index.js # products/ASC.Files/Client/src/store/files/actions.js # products/ASC.Files/Client/src/store/files/reducers.js # products/ASC.Files/Client/src/store/rootReducer.js # products/ASC.People/Client/config-overrides.js # products/ASC.People/Client/package.json # products/ASC.People/Client/src/App.js # products/ASC.People/Client/src/components/Article/Body/index.js # products/ASC.People/Client/src/components/Article/Header/index.js # products/ASC.People/Client/src/components/Article/MainButton/index.js # products/ASC.People/Client/src/components/dialogs/ChangeEmailDialog/index.js # products/ASC.People/Client/src/components/dialogs/ChangePasswordDialog/index.js # products/ASC.People/Client/src/components/dialogs/ChangePhoneDialog/index.js # products/ASC.People/Client/src/components/dialogs/ChangeUserStatusDialog/index.js # products/ASC.People/Client/src/components/dialogs/ChangeUserTypeDialog/index.js # products/ASC.People/Client/src/components/dialogs/DataLossWarningDialog/index.js # products/ASC.People/Client/src/components/dialogs/DeleteProfileEverDialog/index.js # products/ASC.People/Client/src/components/dialogs/DeleteSelfProfileDialog/index.js # products/ASC.People/Client/src/components/dialogs/DeleteUsersDialog/index.js # products/ASC.People/Client/src/components/dialogs/InviteDialog/index.js # products/ASC.People/Client/src/components/dialogs/SendInviteDialog/index.js # products/ASC.People/Client/src/components/pages/GroupAction/Section/Body/index.js # products/ASC.People/Client/src/components/pages/GroupAction/index.js # products/ASC.People/Client/src/components/pages/Home/Section/Body/index.js # products/ASC.People/Client/src/components/pages/Home/Section/Body/userContent.js # products/ASC.People/Client/src/components/pages/Home/Section/Filter/index.js # products/ASC.People/Client/src/components/pages/Home/Section/Header/index.js # products/ASC.People/Client/src/components/pages/Home/Section/Paging/index.js # products/ASC.People/Client/src/components/pages/Home/index.js # products/ASC.People/Client/src/components/pages/Profile/Section/Body/ProfileInfo/ProfileInfo.js # products/ASC.People/Client/src/components/pages/Profile/Section/Body/index.js # products/ASC.People/Client/src/components/pages/Profile/Section/Header/index.js # products/ASC.People/Client/src/components/pages/Profile/index.js # products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/avatarEditorPage.js # products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/createAvatarEditorPage.js # products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/updateUserForm.js # products/ASC.People/Client/src/components/pages/ProfileAction/index.js # products/ASC.People/Client/src/components/pages/Reassign/Section/Header/index.js # products/ASC.People/Client/src/components/pages/Reassign/index.js # products/ASC.People/Client/src/helpers/i18n.js # products/ASC.People/Client/src/helpers/utils.js # products/ASC.People/Client/src/index.js # products/ASC.People/Client/src/store/people/reducers.js # products/ASC.People/Client/src/store/portal/actions.js # products/ASC.People/Client/src/store/portal/reducers.js # products/ASC.People/Client/src/store/profile/actions.js # products/ASC.People/Client/src/store/profile/selectors.js # products/ASC.People/Client/src/store/rootReducer.js # products/ASC.People/Client/yarn.lock # web/ASC.Web.Client/config-overrides.js # web/ASC.Web.Client/package.json # web/ASC.Web.Client/src/App.js # web/ASC.Web.Client/src/components/pages/About/index.js # web/ASC.Web.Client/src/components/pages/Confirm/index.js # web/ASC.Web.Client/src/components/pages/Confirm/sub-components/activateEmail.js # web/ASC.Web.Client/src/components/pages/Confirm/sub-components/activateUser.js # web/ASC.Web.Client/src/components/pages/Confirm/sub-components/changeEmail.js # web/ASC.Web.Client/src/components/pages/Confirm/sub-components/changeOwner.js # web/ASC.Web.Client/src/components/pages/Confirm/sub-components/changePassword.js # web/ASC.Web.Client/src/components/pages/Confirm/sub-components/changePhone.js # web/ASC.Web.Client/src/components/pages/Confirm/sub-components/createUser.js # web/ASC.Web.Client/src/components/pages/Confirm/sub-components/profileRemove.js # web/ASC.Web.Client/src/components/pages/Home/index.js # web/ASC.Web.Client/src/components/pages/PaymentsEnterprise/index.js # web/ASC.Web.Client/src/components/pages/PaymentsEnterprise/sub-components/advantagesContainer.js # web/ASC.Web.Client/src/components/pages/PaymentsEnterprise/sub-components/buttonContainer.js # web/ASC.Web.Client/src/components/pages/PaymentsEnterprise/sub-components/contactContainer.js # web/ASC.Web.Client/src/components/pages/PaymentsEnterprise/sub-components/headerContainer.js # web/ASC.Web.Client/src/components/pages/Settings/Layout/index.js # web/ASC.Web.Client/src/components/pages/Settings/categories/common/custom-titles.js # web/ASC.Web.Client/src/components/pages/Settings/categories/common/customization.js # web/ASC.Web.Client/src/components/pages/Settings/categories/common/language-and-time-zone.js # web/ASC.Web.Client/src/components/pages/Settings/categories/common/whitelabel.js # web/ASC.Web.Client/src/components/pages/Settings/categories/integration/sub-components/consumerModalDialog.js # web/ASC.Web.Client/src/components/pages/Settings/categories/integration/thirdPartyServicesSettings.js # web/ASC.Web.Client/src/components/pages/Settings/categories/security/accessRights.js # web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/admins.js # web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/modules.js # web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/owner.js # web/ASC.Web.Client/src/components/pages/ThirdParty/index.js # web/ASC.Web.Client/src/components/pages/Wizard/index.js # web/ASC.Web.Client/src/helpers/confirmRoute.js # web/ASC.Web.Client/src/helpers/i18n.js # web/ASC.Web.Client/src/helpers/utils.js # web/ASC.Web.Client/src/index.js # web/ASC.Web.Client/src/store/confirm/actions.js # web/ASC.Web.Client/src/store/payments/actions.js # web/ASC.Web.Client/src/store/settings/reducer.js # web/ASC.Web.Client/src/store/settings/selectors.js # web/ASC.Web.Client/src/store/store.js # web/ASC.Web.Client/src/store/wizard/actions.js # web/ASC.Web.Client/yarn.lock # web/ASC.Web.Common/package.json # web/ASC.Web.Common/yarn.lock # web/ASC.Web.Components/package.json # web/ASC.Web.Components/yarn.lock # web/ASC.Web.Login/src/Login.jsx # web/ASC.Web.Login/src/sub-components/register-container.js # yarn.lock
2021-02-24 07:30:42 +00:00
port: 5011,
historyApiFallback: {
// Paths with dots should still use the history fallback.
// See https://github.com/facebook/create-react-app/issues/387.
disableDotRule: true,
index: homepage,
},
hot: false,
headers: {
2021-12-21 07:59:11 +00:00
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization',
},
},
2020-11-24 10:20:14 +00:00
output: {
2021-12-21 07:59:11 +00:00
publicPath: 'auto',
chunkFilename: 'static/js/[id].[contenthash].js',
//assetModuleFilename: "static/images/[hash][ext][query]",
2021-12-21 07:59:11 +00:00
path: path.resolve(process.cwd(), 'dist'),
filename: 'static/js/[name].[contenthash].bundle.js',
2020-11-24 10:20:14 +00:00
},
resolve: {
2021-12-21 07:59:11 +00:00
extensions: ['.jsx', '.js', '.json'],
2020-11-26 16:42:15 +00:00
fallback: {
crypto: false,
},
2020-11-24 10:20:14 +00:00
},
performance: {
maxEntrypointSize: 512000,
maxAssetSize: 512000,
},
2020-11-24 10:20:14 +00:00
module: {
rules: [
2021-03-10 16:24:15 +00:00
{
2021-03-10 16:33:10 +00:00
test: /\.(png|jpe?g|gif|ico)$/i,
2021-12-21 07:59:11 +00:00
type: 'asset/resource',
generator: {
2021-12-21 07:59:11 +00:00
filename: 'static/images/[hash][ext][query]',
},
2021-03-10 16:24:15 +00:00
},
2020-11-24 10:20:14 +00:00
{
test: /\.m?js/,
2021-12-21 07:59:11 +00:00
type: 'javascript/auto',
2020-11-24 10:20:14 +00:00
resolve: {
fullySpecified: false,
},
},
{
test: /\.react.svg$/,
use: [
{
2021-12-21 07:59:11 +00:00
loader: '@svgr/webpack',
options: {
svgoConfig: {
2021-03-10 16:24:15 +00:00
plugins: [{ removeViewBox: false }],
},
},
},
],
2020-11-24 10:20:14 +00:00
},
2021-12-21 07:59:11 +00:00
{ test: /\.json$/, loader: 'json-loader' },
{
test: /\.css$/i,
2021-12-21 07:59:11 +00:00
use: ['style-loader', 'css-loader'],
},
2020-11-24 10:20:14 +00:00
{
test: /\.s[ac]ss$/i,
use: [
// Creates `style` nodes from JS strings
2021-12-21 07:59:11 +00:00
'style-loader',
// Translates CSS into CommonJS
{
2021-12-21 07:59:11 +00:00
loader: 'css-loader',
options: {
url: {
filter: (url, resourcePath) => {
// resourcePath - path to css file
// Don't handle `/static` urls
2021-12-21 07:59:11 +00:00
if (url.startsWith('/static') || url.startsWith('data:')) {
return false;
}
return true;
},
},
},
},
// Compiles Sass to CSS
2021-12-21 07:59:11 +00:00
'sass-loader',
],
2020-11-24 10:20:14 +00:00
},
2020-11-24 10:20:14 +00:00
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: [
{
2021-12-21 07:59:11 +00:00
loader: 'babel-loader',
2020-11-24 10:20:14 +00:00
options: {
2021-12-21 07:59:11 +00:00
presets: ['@babel/preset-react', '@babel/preset-env'],
2020-11-24 10:20:14 +00:00
plugins: [
2021-12-21 07:59:11 +00:00
'@babel/plugin-transform-runtime',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-export-default-from',
2020-11-24 10:20:14 +00:00
],
},
},
2021-12-21 07:59:11 +00:00
'source-map-loader',
2020-11-24 10:20:14 +00:00
],
},
],
},
plugins: [
new CleanWebpackPlugin(),
2020-11-24 10:20:14 +00:00
new ModuleFederationPlugin({
2021-12-21 07:59:11 +00:00
name: 'login',
filename: 'remoteEntry.js',
remotes: {
2021-12-21 07:59:11 +00:00
studio: `studio@${combineUrl(proxyURL, '/remoteEntry.js')}`,
},
exposes: {
2021-12-21 07:59:11 +00:00
'./app': './src/Login.jsx',
},
2020-11-24 10:20:14 +00:00
shared: {
...deps,
...sharedDeps,
2020-11-24 10:20:14 +00:00
},
}),
2021-07-23 14:20:42 +00:00
new ExternalTemplateRemotesPlugin(),
new HtmlWebpackPlugin({
2021-12-21 07:59:11 +00:00
template: './public/index.html',
publicPath: homepage,
2021-03-10 16:24:15 +00:00
title: title,
// templateParameters: {
// proxyURL: proxyURL,
// },
base: `${homepage}/`,
}),
new CopyPlugin({
patterns: [
{
2021-12-21 07:59:11 +00:00
from: 'public',
globOptions: {
dot: true,
gitignore: true,
2021-12-21 07:59:11 +00:00
ignore: ['**/index.html'],
},
},
],
2020-11-24 10:20:14 +00:00
}),
],
};
module.exports = (env, argv) => {
2021-12-21 07:59:11 +00:00
if (argv.mode === 'production') {
config.mode = 'production';
2021-03-10 16:24:15 +00:00
config.optimization = {
2021-12-21 07:59:11 +00:00
splitChunks: { chunks: 'all' },
minimize: !env.minimize,
2021-03-10 16:24:15 +00:00
minimizer: [new TerserPlugin()],
};
2021-03-01 15:21:40 +00:00
} else {
2021-12-21 07:59:11 +00:00
config.devtool = 'cheap-module-source-map';
}
return config;
};