2021-08-05 02:31:54 +03:00
|
|
|
//
|
|
|
|
// Copyright © 2020 Anticrm Platform Contributors.
|
|
|
|
//
|
|
|
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License. You may
|
|
|
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
//
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
|
|
|
const Dotenv = require('dotenv-webpack')
|
|
|
|
const path = require('path')
|
|
|
|
const autoprefixer = require('autoprefixer')
|
2021-11-22 14:17:10 +03:00
|
|
|
const CompressionPlugin = require('compression-webpack-plugin')
|
|
|
|
const DefinePlugin = require('webpack').DefinePlugin
|
2021-08-05 02:31:54 +03:00
|
|
|
|
|
|
|
const mode = process.env.NODE_ENV || 'development'
|
|
|
|
const prod = mode === 'production'
|
2021-11-22 14:17:10 +03:00
|
|
|
const devServer = (process.env.CLIENT_TYPE ?? '') === 'dev-server'
|
2021-08-05 02:31:54 +03:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
entry: {
|
|
|
|
bundle: [
|
|
|
|
'@anticrm/theme/styles/global.scss',
|
|
|
|
'./src/main.ts'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
symlinks: true,
|
|
|
|
alias: {
|
|
|
|
svelte: path.resolve('./node_modules', 'svelte')
|
|
|
|
},
|
|
|
|
extensions: ['.mjs', '.js', '.svelte', '.ts'],
|
|
|
|
mainFields: ['svelte', 'browser', 'module', 'main']
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
path: __dirname + '/dist',
|
|
|
|
filename: '[name].js',
|
|
|
|
chunkFilename: '[name].[id].js',
|
|
|
|
publicPath: '/'
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.ts?$/,
|
|
|
|
use: 'ts-loader',
|
|
|
|
exclude: /node_modules/
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.svelte$/,
|
|
|
|
use: {
|
|
|
|
loader: 'svelte-loader',
|
|
|
|
options: {
|
|
|
|
emitCss: true,
|
|
|
|
preprocess: require('svelte-preprocess')({ postcss: true })
|
|
|
|
}
|
|
|
|
// options: {
|
|
|
|
// dev: !prod,
|
|
|
|
// emitCss: true,
|
|
|
|
// hotReload: !prod,
|
|
|
|
// preprocess: require('svelte-preprocess')({
|
|
|
|
// babel: {
|
|
|
|
// presets: [
|
|
|
|
// [
|
|
|
|
// '@babel/preset-env',
|
|
|
|
// {
|
|
|
|
// loose: true,
|
|
|
|
// modules: false,
|
|
|
|
// targets: {
|
|
|
|
// esmodules: true
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// ],
|
|
|
|
// '@babel/typescript'
|
|
|
|
// ],
|
|
|
|
// plugins: ['@babel/plugin-proposal-optional-chaining']
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
use: [
|
|
|
|
prod ? MiniCssExtractPlugin.loader : 'style-loader',
|
|
|
|
'css-loader',
|
|
|
|
'postcss-loader'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
test: /\.scss$/,
|
|
|
|
use: [
|
|
|
|
prod ? MiniCssExtractPlugin.loader : 'style-loader',
|
|
|
|
'css-loader',
|
|
|
|
'postcss-loader',
|
|
|
|
'sass-loader',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
test: /\.(ttf|otf|eot|woff|woff2)$/,
|
|
|
|
use: {
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
2021-08-06 10:41:02 +03:00
|
|
|
name: 'fonts/[hash:base64:8].[ext]',
|
2021-08-05 02:31:54 +03:00
|
|
|
esModule: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(jpg|png)$/,
|
|
|
|
use: {
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
2021-08-06 10:41:02 +03:00
|
|
|
name: 'img/[hash:base64:8].[ext]',
|
2021-08-05 02:31:54 +03:00
|
|
|
esModule: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.svg$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
2021-08-06 10:41:02 +03:00
|
|
|
name: 'img/[hash:base64:8].[ext]',
|
2021-08-05 02:31:54 +03:00
|
|
|
esModule: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'svgo-loader',
|
|
|
|
options: {
|
|
|
|
plugins: [
|
|
|
|
{ name: 'removeHiddenElems', active: false }
|
|
|
|
// { removeHiddenElems: { displayNone: false } },
|
|
|
|
// { cleanupIDs: false },
|
|
|
|
// { removeTitle: true }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
mode,
|
|
|
|
plugins: [
|
2021-11-22 14:17:10 +03:00
|
|
|
...(prod ? [new CompressionPlugin()] : []),
|
2021-08-05 02:31:54 +03:00
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: '[name].css'
|
|
|
|
}),
|
2021-11-22 14:17:10 +03:00
|
|
|
new Dotenv({path: prod ? '.env-prod' : '.env'}),
|
|
|
|
new DefinePlugin({
|
|
|
|
'process.env.CLIENT_TYPE': JSON.stringify(process.env.CLIENT_TYPE)
|
|
|
|
})
|
2021-08-05 02:31:54 +03:00
|
|
|
],
|
|
|
|
devtool: prod ? false : 'source-map',
|
|
|
|
devServer: {
|
|
|
|
publicPath: '/',
|
|
|
|
historyApiFallback: {
|
|
|
|
disableDotRule: true
|
2021-08-08 15:52:05 +03:00
|
|
|
},
|
2021-11-22 14:17:10 +03:00
|
|
|
proxy: devServer ? {
|
|
|
|
'/account': {
|
|
|
|
target: 'http://localhost:3000',
|
|
|
|
changeOrigin: true,
|
|
|
|
pathRewrite: { '^/account': '' },
|
|
|
|
logLevel: 'debug'
|
|
|
|
},
|
|
|
|
'/files': {
|
|
|
|
target: 'http://localhost:8081',
|
|
|
|
changeOrigin: true,
|
|
|
|
logLevel: 'debug'
|
|
|
|
},
|
|
|
|
} : {
|
2021-08-17 16:09:15 +03:00
|
|
|
'/account': {
|
2021-09-10 18:06:51 +03:00
|
|
|
// target: 'https://ftwm71rwag.execute-api.us-west-2.amazonaws.com/stage/',
|
|
|
|
target: 'https://account.hc.engineering/',
|
2021-08-08 15:52:05 +03:00
|
|
|
changeOrigin: true,
|
2021-08-17 16:09:15 +03:00
|
|
|
pathRewrite: { '^/account': '' },
|
|
|
|
logLevel: 'debug'
|
|
|
|
},
|
2021-11-22 14:17:10 +03:00
|
|
|
'/files': {
|
2021-08-28 13:05:36 +03:00
|
|
|
// target: 'https://anticrm-upload.herokuapp.com/',
|
2021-11-22 14:17:10 +03:00
|
|
|
// target: 'http://localhost:3000/',
|
2021-10-25 18:11:48 +03:00
|
|
|
target: 'https://front.hc.engineering/files',
|
2021-08-17 16:09:15 +03:00
|
|
|
changeOrigin: true,
|
2021-11-22 14:17:10 +03:00
|
|
|
pathRewrite: { '^/files': '' },
|
2021-08-08 15:52:05 +03:00
|
|
|
logLevel: 'debug'
|
|
|
|
},
|
2021-08-05 02:31:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|