@raisenow/tamaro-cli 1.1.7 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/prettier.xml +6 -0
- package/.idea/runConfigurations/build_watch.xml +13 -0
- package/.idea/runConfigurations/lint_fix.xml +13 -0
- package/.idea/runConfigurations/tscheck.xml +12 -0
- package/.idea/tamaro-cli.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/.nvmrc +1 -1
- package/README.md +35 -13
- package/bitbucket-pipelines.yml +43 -0
- package/dist/{chunk-NJVU7WR2.js → chunk-KVWFHWZD.js} +4 -5
- package/dist/cli.js +48 -10
- package/dist/webpack.config.js +17 -11
- package/package.json +10 -9
- package/src/cli.ts +0 -178
- package/src/commands/build.ts +0 -131
- package/src/commands/deploy-email-config.ts +0 -159
- package/src/commands/deploy.ts +0 -164
- package/src/commands/dev.ts +0 -88
- package/src/commands/list-deployed.ts +0 -117
- package/src/commands/serve.ts +0 -69
- package/src/lib/InterpolateHtmlPlugin.ts +0 -47
- package/src/lib/aws.ts +0 -138
- package/src/lib/command.ts +0 -27
- package/src/lib/constants.ts +0 -9
- package/src/lib/env.ts +0 -176
- package/src/lib/https.ts +0 -27
- package/src/lib/logging.ts +0 -37
- package/src/lib/notifier.ts +0 -22
- package/src/lib/resolve.ts +0 -143
- package/src/webpack.config.ts +0 -429
- package/tsconfig.json +0 -38
package/src/lib/https.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import {existsSync} from 'fs'
|
|
2
|
-
import {resolve} from 'path'
|
|
3
|
-
import stripIndent from 'strip-indent'
|
|
4
|
-
import {halt} from 'lib/command'
|
|
5
|
-
import {HTTPS_CRT_FILE, HTTPS_KEY_FILE} from 'lib/constants'
|
|
6
|
-
import {getIfCoreFns, getPaths} from 'lib/resolve'
|
|
7
|
-
|
|
8
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
9
|
-
|
|
10
|
-
export const assertCrtExists = () => {
|
|
11
|
-
const {ifCore} = getIfCoreFns()
|
|
12
|
-
const paths = getPaths(ifCore)
|
|
13
|
-
const certFile = resolve(paths.root, HTTPS_CRT_FILE)
|
|
14
|
-
const keyFile = resolve(paths.root, HTTPS_KEY_FILE)
|
|
15
|
-
|
|
16
|
-
if (existsSync(certFile) && existsSync(keyFile)) {
|
|
17
|
-
return
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
halt(
|
|
21
|
-
stripIndent(`
|
|
22
|
-
Flag "--https" is used, but "${HTTPS_CRT_FILE}" and/or "${HTTPS_KEY_FILE}" files are not found.
|
|
23
|
-
You need to generate certificate first.
|
|
24
|
-
Check docs: https://unpkg.com/@raisenow/tamaro-cli/readme.html#/?id=use-transport-level-security-https
|
|
25
|
-
`),
|
|
26
|
-
)
|
|
27
|
-
}
|
package/src/lib/logging.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import columnify from 'columnify'
|
|
3
|
-
import stripIndent from 'strip-indent'
|
|
4
|
-
|
|
5
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
6
|
-
|
|
7
|
-
export const logTitle = (title: string) => {
|
|
8
|
-
// eslint-disable-next-line no-console
|
|
9
|
-
console.log(chalk.bold(title))
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
13
|
-
|
|
14
|
-
export const logError = (message?: string) => {
|
|
15
|
-
if (message) {
|
|
16
|
-
// eslint-disable-next-line no-console
|
|
17
|
-
console.log(chalk.red(message))
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
22
|
-
|
|
23
|
-
export const logCommand = (cmd: string): void => {
|
|
24
|
-
// eslint-disable-next-line no-console
|
|
25
|
-
console.log(`\n${chalk.dim(stripIndent(cmd).trim())}\n`)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
29
|
-
|
|
30
|
-
export const logDataTable = (
|
|
31
|
-
data: Record<string, string | undefined>,
|
|
32
|
-
): void => {
|
|
33
|
-
// eslint-disable-next-line no-console
|
|
34
|
-
console.log(columnify(data, {showHeaders: false}))
|
|
35
|
-
// eslint-disable-next-line no-console
|
|
36
|
-
console.log('')
|
|
37
|
-
}
|
package/src/lib/notifier.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import notifier from 'node-notifier'
|
|
2
|
-
import stripIndent from 'strip-indent'
|
|
3
|
-
|
|
4
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
-
|
|
6
|
-
export type NotifyArgs = {
|
|
7
|
-
title: string
|
|
8
|
-
message: string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
12
|
-
|
|
13
|
-
export const notify = (args: NotifyArgs) => {
|
|
14
|
-
const {title, message = ''} = args
|
|
15
|
-
|
|
16
|
-
notifier.notify({
|
|
17
|
-
title,
|
|
18
|
-
message: stripIndent(message).trim(),
|
|
19
|
-
contentImage: 'https://assets.raisenow.io/favicon.png',
|
|
20
|
-
sound: 'Funk',
|
|
21
|
-
})
|
|
22
|
-
}
|
package/src/lib/resolve.ts
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import {existsSync, realpathSync} from 'fs'
|
|
2
|
-
import {createRequire} from 'module'
|
|
3
|
-
import {basename, dirname, join, relative, resolve} from 'path'
|
|
4
|
-
import chalk from 'chalk'
|
|
5
|
-
import stripIndent from 'strip-indent'
|
|
6
|
-
import {getIfUtils, type IfUtils, type IfUtilsFn} from 'webpack-config-utils'
|
|
7
|
-
import {logError} from 'lib/logging'
|
|
8
|
-
|
|
9
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
10
|
-
|
|
11
|
-
export type ResolveFn = (relativePath: string) => string
|
|
12
|
-
|
|
13
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
14
|
-
|
|
15
|
-
const require = createRequire(import.meta.url)
|
|
16
|
-
export const moduleFileExtensions = ['ts', 'tsx', 'js', 'jsx']
|
|
17
|
-
export const extensions = moduleFileExtensions.map((v) => `.${v}`)
|
|
18
|
-
|
|
19
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
20
|
-
|
|
21
|
-
const TAMARO_CORE_PACKAGE_NAMES = ['@raisenow/tamaro-core']
|
|
22
|
-
const TAMARO_CONFIGURATIONS_PACKAGE_NAMES = ['@raisenow/tamaro-configurations']
|
|
23
|
-
const TAMARO_SELF_SERVICE_PACKAGE_NAMES = ['@raisenow/tamaro-self-service']
|
|
24
|
-
|
|
25
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
26
|
-
|
|
27
|
-
export const resolveApp: ResolveFn = (relativePath) =>
|
|
28
|
-
resolve(realpathSync(process.cwd()), relativePath)
|
|
29
|
-
|
|
30
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
31
|
-
|
|
32
|
-
// __dirname is "dist" in runtime
|
|
33
|
-
export const resolveOwn: ResolveFn = (relativePath) =>
|
|
34
|
-
resolve(__dirname, '..', relativePath)
|
|
35
|
-
|
|
36
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
37
|
-
|
|
38
|
-
export const resolveModule = (resolveFn: ResolveFn, filePath: string) => {
|
|
39
|
-
const extension = moduleFileExtensions.find((extension) =>
|
|
40
|
-
existsSync(resolveFn(`${filePath}.${extension}`)),
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
if (extension) {
|
|
44
|
-
return resolveFn(`${filePath}.${extension}`)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return resolveFn(`${filePath}.js`)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
51
|
-
|
|
52
|
-
export const resolveBin = (name: string) => {
|
|
53
|
-
const pkgPath = require.resolve(`${name}/package.json`)
|
|
54
|
-
const {bin} = require(pkgPath)
|
|
55
|
-
const dir = dirname(pkgPath)
|
|
56
|
-
const binPath: string = typeof bin === 'object' ? bin[name] : bin
|
|
57
|
-
|
|
58
|
-
return join(dir, binPath)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
62
|
-
|
|
63
|
-
export const getWidgetUuid = () => basename(resolveApp('.'))
|
|
64
|
-
|
|
65
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
66
|
-
|
|
67
|
-
export const getPaths = (ifCore: IfUtilsFn) => {
|
|
68
|
-
return ifCore(
|
|
69
|
-
{
|
|
70
|
-
root: resolveApp('.'),
|
|
71
|
-
app: resolveApp('.'),
|
|
72
|
-
appEntry: resolveModule(resolveApp, 'src/index'),
|
|
73
|
-
appDist: resolveApp('dist'),
|
|
74
|
-
appNodeModules: resolveApp('node_modules'),
|
|
75
|
-
appTsConfig: resolveApp('tsconfig.json'),
|
|
76
|
-
appHtml: resolveApp('src/*.html'),
|
|
77
|
-
appEnv: resolveApp('.env*'),
|
|
78
|
-
appTailwindConfig: resolveApp('tailwind.config.js'),
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
root: resolveApp('../..'),
|
|
82
|
-
app: resolveApp('.'),
|
|
83
|
-
appEntry: resolveModule(resolveApp, 'widget'),
|
|
84
|
-
appDist: resolveApp(`../../dist/${getWidgetUuid()}`),
|
|
85
|
-
appNodeModules: resolveApp('../../node_modules'),
|
|
86
|
-
appTsConfig: resolveApp('tsconfig.json'),
|
|
87
|
-
appHtml: resolveApp('*.html'),
|
|
88
|
-
appEnv: resolveApp('.env*'),
|
|
89
|
-
appTailwindConfig: undefined,
|
|
90
|
-
},
|
|
91
|
-
)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
95
|
-
|
|
96
|
-
type Paths = Record<string, string | undefined>
|
|
97
|
-
|
|
98
|
-
export const getRelativePaths = (paths: Paths): Paths => {
|
|
99
|
-
const relativePaths: Paths = {}
|
|
100
|
-
|
|
101
|
-
for (const [type, absPath] of Object.entries(paths)) {
|
|
102
|
-
if (absPath) {
|
|
103
|
-
relativePaths[type] = relative('./', absPath) || '.'
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return relativePaths
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
111
|
-
|
|
112
|
-
export const getIfCoreFns = (): IfUtils => {
|
|
113
|
-
const corePkgPath = resolveApp('package.json')
|
|
114
|
-
const configsPkgPath = resolveApp('../../package.json')
|
|
115
|
-
let packageName
|
|
116
|
-
|
|
117
|
-
if (existsSync(corePkgPath)) {
|
|
118
|
-
packageName = require(corePkgPath).name
|
|
119
|
-
} else if (existsSync(configsPkgPath)) {
|
|
120
|
-
packageName = require(configsPkgPath).name
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (packageName) {
|
|
124
|
-
return getIfUtils({core: TAMARO_CORE_PACKAGE_NAMES.includes(packageName)}, [
|
|
125
|
-
'core',
|
|
126
|
-
])
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
logError(
|
|
130
|
-
stripIndent(`\
|
|
131
|
-
You must run "npx @raisenow/tamaro-cli" commands from:
|
|
132
|
-
1. Root of "${chalk.bold(TAMARO_CORE_PACKAGE_NAMES[0])}" package folder.
|
|
133
|
-
2. Root of particular customer configuration folder of "${chalk.bold(
|
|
134
|
-
TAMARO_CONFIGURATIONS_PACKAGE_NAMES[0],
|
|
135
|
-
)}" package.
|
|
136
|
-
3. "src/self-service" folder of "${chalk.bold(
|
|
137
|
-
TAMARO_SELF_SERVICE_PACKAGE_NAMES[0],
|
|
138
|
-
)}" package.
|
|
139
|
-
You are currently in "${chalk.bold(realpathSync(process.cwd()))}".
|
|
140
|
-
`),
|
|
141
|
-
)
|
|
142
|
-
process.exit(1)
|
|
143
|
-
}
|
package/src/webpack.config.ts
DELETED
|
@@ -1,429 +0,0 @@
|
|
|
1
|
-
import {existsSync} from 'fs'
|
|
2
|
-
import {createRequire} from 'module'
|
|
3
|
-
import {basename, dirname, resolve} from 'path'
|
|
4
|
-
import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin'
|
|
5
|
-
import StatoscopeWebpackPlugin from '@statoscope/webpack-plugin'
|
|
6
|
-
import {CleanWebpackPlugin} from 'clean-webpack-plugin'
|
|
7
|
-
import CopyPlugin from 'copy-webpack-plugin'
|
|
8
|
-
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin'
|
|
9
|
-
import ESLintPlugin from 'eslint-webpack-plugin'
|
|
10
|
-
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'
|
|
11
|
-
import {globSync} from 'glob'
|
|
12
|
-
import HtmlWebpackPlugin from 'html-webpack-plugin'
|
|
13
|
-
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
|
14
|
-
import {TsconfigPathsPlugin} from 'tsconfig-paths-webpack-plugin'
|
|
15
|
-
import type {Configuration, RuleSetUseItem} from 'webpack'
|
|
16
|
-
// eslint-disable-next-line import/no-named-as-default
|
|
17
|
-
import webpack from 'webpack'
|
|
18
|
-
import {getIfUtils, removeEmpty} from 'webpack-config-utils'
|
|
19
|
-
// Needed for webpack-dev-server types to be picked up correctly
|
|
20
|
-
import {} from 'webpack-dev-server'
|
|
21
|
-
import {HTTPS_CRT_FILE, HTTPS_KEY_FILE} from 'lib/constants'
|
|
22
|
-
import {getEnvVars} from 'lib/env'
|
|
23
|
-
import {InterpolateHtmlPlugin} from 'lib/InterpolateHtmlPlugin'
|
|
24
|
-
import {logDataTable, logTitle} from 'lib/logging'
|
|
25
|
-
import {
|
|
26
|
-
extensions,
|
|
27
|
-
getIfCoreFns,
|
|
28
|
-
getPaths,
|
|
29
|
-
getRelativePaths,
|
|
30
|
-
moduleFileExtensions,
|
|
31
|
-
resolveApp,
|
|
32
|
-
} from 'lib/resolve'
|
|
33
|
-
|
|
34
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
35
|
-
|
|
36
|
-
const require = createRequire(import.meta.url)
|
|
37
|
-
const imageInlineSizeLimit = 0
|
|
38
|
-
// const imageInlineSizeLimit = 8 * 1024 // 8kb
|
|
39
|
-
|
|
40
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
41
|
-
|
|
42
|
-
const getWebpackConfig = (env: any): Configuration => {
|
|
43
|
-
const {ifMin, ifNotMin} = getIfUtils(env, ['min'])
|
|
44
|
-
const {ifAnalyze} = getIfUtils(env, ['analyze'])
|
|
45
|
-
const {ifHttps} = getIfUtils(env, ['https'])
|
|
46
|
-
const {ifLocalCore} = getIfUtils(env, ['localCore'])
|
|
47
|
-
const {ifCore} = getIfCoreFns()
|
|
48
|
-
const paths = getPaths(ifCore)
|
|
49
|
-
const appHtmlFiles = globSync(paths.appHtml)
|
|
50
|
-
const appEnvFiles = globSync(paths.appEnv)
|
|
51
|
-
const envVars = getEnvVars(appEnvFiles, ifMin, ifCore, ifLocalCore, ifHttps)
|
|
52
|
-
const {ifHmr} = getIfUtils({hmr: process.env.HMR_ENABLED === 'true'}, ['hmr'])
|
|
53
|
-
const {ifNolint} = getIfUtils(env, ['nolint'])
|
|
54
|
-
const useTailwind =
|
|
55
|
-
ifCore() && paths.appTailwindConfig && existsSync(paths.appTailwindConfig)
|
|
56
|
-
|
|
57
|
-
logTitle('Paths:')
|
|
58
|
-
logDataTable(getRelativePaths(paths))
|
|
59
|
-
|
|
60
|
-
logTitle('Environment variables:')
|
|
61
|
-
logDataTable(envVars.raw)
|
|
62
|
-
|
|
63
|
-
const getCssLoaders = (cssOptions: any = {}): RuleSetUseItem[] => {
|
|
64
|
-
return removeEmpty([
|
|
65
|
-
ifMin({loader: MiniCssExtractPlugin.loader}),
|
|
66
|
-
ifNotMin({
|
|
67
|
-
loader: require.resolve('style-loader'),
|
|
68
|
-
options: {
|
|
69
|
-
attributes: {
|
|
70
|
-
'data-widget': process.env.ELEMENT_ATTRIBUTE_DATA_WIDGET,
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
}),
|
|
74
|
-
{
|
|
75
|
-
loader: require.resolve('css-loader'),
|
|
76
|
-
options: {
|
|
77
|
-
sourceMap: ifNotMin(),
|
|
78
|
-
importLoaders: 3,
|
|
79
|
-
...cssOptions,
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
loader: require.resolve('postcss-loader'),
|
|
84
|
-
options: {
|
|
85
|
-
postcssOptions: {
|
|
86
|
-
plugins: removeEmpty([
|
|
87
|
-
useTailwind
|
|
88
|
-
? [
|
|
89
|
-
require.resolve('tailwindcss', {
|
|
90
|
-
paths: [paths.appNodeModules],
|
|
91
|
-
}),
|
|
92
|
-
paths.appTailwindConfig,
|
|
93
|
-
]
|
|
94
|
-
: undefined,
|
|
95
|
-
require.resolve('postcss-custom-properties'),
|
|
96
|
-
require.resolve('autoprefixer'),
|
|
97
|
-
]),
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
loader: require.resolve('resolve-url-loader'),
|
|
103
|
-
options: {sourceMap: ifNotMin()},
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
loader: require.resolve('sass-loader'),
|
|
107
|
-
options: {api: 'modern-compiler', sourceMap: true},
|
|
108
|
-
},
|
|
109
|
-
])
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const config: Configuration = {
|
|
113
|
-
mode: ifMin('production', 'development'),
|
|
114
|
-
resolve: {
|
|
115
|
-
symlinks: false,
|
|
116
|
-
extensions: [...extensions, '...'],
|
|
117
|
-
modules: ['node_modules', paths.appNodeModules],
|
|
118
|
-
plugins: [
|
|
119
|
-
new TsconfigPathsPlugin({
|
|
120
|
-
configFile: paths.appTsConfig,
|
|
121
|
-
extensions,
|
|
122
|
-
}),
|
|
123
|
-
],
|
|
124
|
-
},
|
|
125
|
-
entry: paths.appEntry,
|
|
126
|
-
output: {
|
|
127
|
-
publicPath: 'auto',
|
|
128
|
-
path: ifMin(paths.appDist, undefined),
|
|
129
|
-
pathinfo: false,
|
|
130
|
-
filename: ifCore('index.js', 'widget.js'),
|
|
131
|
-
chunkFilename: ifMin('[name]-[contenthash:16].js', '[name].js'),
|
|
132
|
-
assetModuleFilename: 'assets/[name]-[contenthash:16][ext]',
|
|
133
|
-
crossOriginLoading: 'anonymous',
|
|
134
|
-
uniqueName: process.env.WEBPACK_UNIQUE_NAME,
|
|
135
|
-
},
|
|
136
|
-
stats: ifAnalyze(
|
|
137
|
-
{
|
|
138
|
-
all: undefined,
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
modules: false,
|
|
142
|
-
children: false,
|
|
143
|
-
chunks: false,
|
|
144
|
-
env: true,
|
|
145
|
-
entrypoints: true,
|
|
146
|
-
errorDetails: true,
|
|
147
|
-
},
|
|
148
|
-
),
|
|
149
|
-
module: {
|
|
150
|
-
rules: removeEmpty([
|
|
151
|
-
// Source maps
|
|
152
|
-
ifNotMin({
|
|
153
|
-
enforce: 'pre',
|
|
154
|
-
exclude: /@babel\/runtime/,
|
|
155
|
-
test: /\.(js|jsx|ts|tsx|css|scss)$/,
|
|
156
|
-
use: require.resolve('source-map-loader'),
|
|
157
|
-
}),
|
|
158
|
-
|
|
159
|
-
{
|
|
160
|
-
oneOf: [
|
|
161
|
-
/**
|
|
162
|
-
* App Javascript and Typescript (Babel)
|
|
163
|
-
* and some dependencies distributed in a non-es5 formats
|
|
164
|
-
*/
|
|
165
|
-
{
|
|
166
|
-
test: /\.(js|ts)x?$/,
|
|
167
|
-
include: ifCore(
|
|
168
|
-
[
|
|
169
|
-
resolveApp('src'),
|
|
170
|
-
resolveApp('node_modules/micromark'),
|
|
171
|
-
resolveApp('node_modules/decode-named-character-reference'),
|
|
172
|
-
],
|
|
173
|
-
[resolveApp('.'), resolveApp('../../src')],
|
|
174
|
-
),
|
|
175
|
-
|
|
176
|
-
loader: require.resolve('babel-loader'),
|
|
177
|
-
options: {
|
|
178
|
-
babelrc: false,
|
|
179
|
-
configFile: false,
|
|
180
|
-
sourceMaps: ifNotMin(),
|
|
181
|
-
inputSourceMap: ifNotMin(),
|
|
182
|
-
presets: [
|
|
183
|
-
require.resolve('@babel/preset-env'),
|
|
184
|
-
[
|
|
185
|
-
require.resolve('@babel/preset-typescript'),
|
|
186
|
-
{
|
|
187
|
-
allowDeclareFields: true,
|
|
188
|
-
},
|
|
189
|
-
],
|
|
190
|
-
require.resolve('@babel/preset-react'),
|
|
191
|
-
],
|
|
192
|
-
plugins: removeEmpty([
|
|
193
|
-
[
|
|
194
|
-
require.resolve('@babel/plugin-transform-runtime'),
|
|
195
|
-
{
|
|
196
|
-
corejs: {
|
|
197
|
-
version: 3,
|
|
198
|
-
proposals: true,
|
|
199
|
-
},
|
|
200
|
-
absoluteRuntime: dirname(
|
|
201
|
-
require.resolve('@babel/runtime-corejs3/package.json'),
|
|
202
|
-
),
|
|
203
|
-
},
|
|
204
|
-
],
|
|
205
|
-
[
|
|
206
|
-
require.resolve('@babel/plugin-proposal-decorators'),
|
|
207
|
-
{
|
|
208
|
-
legacy: true,
|
|
209
|
-
},
|
|
210
|
-
],
|
|
211
|
-
require.resolve('@babel/plugin-syntax-dynamic-import'),
|
|
212
|
-
require.resolve('babel-plugin-lodash'),
|
|
213
|
-
ifHmr(require.resolve('react-refresh/babel')),
|
|
214
|
-
ifNotMin(require.resolve('babel-plugin-istanbul')),
|
|
215
|
-
]),
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
|
|
219
|
-
// Other Javascript (not in app) - no transformation
|
|
220
|
-
{
|
|
221
|
-
test: /\.(js|mjs)$/,
|
|
222
|
-
},
|
|
223
|
-
|
|
224
|
-
// Styles (not modules)
|
|
225
|
-
{
|
|
226
|
-
test: /\.s?css$/,
|
|
227
|
-
exclude: /\.module\.s?css$/,
|
|
228
|
-
use: getCssLoaders({
|
|
229
|
-
modules: false,
|
|
230
|
-
}),
|
|
231
|
-
},
|
|
232
|
-
|
|
233
|
-
// Styles (modules)
|
|
234
|
-
{
|
|
235
|
-
test: /\.module\.s?css$/,
|
|
236
|
-
use: getCssLoaders({
|
|
237
|
-
modules: {localIdentName: '[local]__[hash:base64]'},
|
|
238
|
-
}),
|
|
239
|
-
},
|
|
240
|
-
|
|
241
|
-
// Images and fonts
|
|
242
|
-
{
|
|
243
|
-
test: /\.(png|jpe?g|svg|webp|gif|ico|ttf|eot|woff2?)$/,
|
|
244
|
-
type: 'asset',
|
|
245
|
-
parser: {
|
|
246
|
-
dataUrlCondition: {
|
|
247
|
-
maxSize: imageInlineSizeLimit,
|
|
248
|
-
},
|
|
249
|
-
},
|
|
250
|
-
},
|
|
251
|
-
|
|
252
|
-
// YML
|
|
253
|
-
{
|
|
254
|
-
test: /\.ya?ml$/,
|
|
255
|
-
use: [
|
|
256
|
-
{loader: require.resolve('json-loader')},
|
|
257
|
-
{
|
|
258
|
-
loader: require.resolve('yaml-loader'),
|
|
259
|
-
options: {asJSON: true},
|
|
260
|
-
},
|
|
261
|
-
],
|
|
262
|
-
},
|
|
263
|
-
|
|
264
|
-
// HTML
|
|
265
|
-
{
|
|
266
|
-
test: /\.html$/,
|
|
267
|
-
loader: require.resolve('html-loader'),
|
|
268
|
-
options: {
|
|
269
|
-
minimize: false,
|
|
270
|
-
},
|
|
271
|
-
},
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* All other files - fallback
|
|
275
|
-
* This must be the latest rule!
|
|
276
|
-
*/
|
|
277
|
-
{
|
|
278
|
-
exclude: [/^$/, /\.(js|jsx|ts|tsx|mjs)$/, /\.html$/, /\.json$/],
|
|
279
|
-
type: 'asset/resource',
|
|
280
|
-
},
|
|
281
|
-
],
|
|
282
|
-
},
|
|
283
|
-
]),
|
|
284
|
-
},
|
|
285
|
-
|
|
286
|
-
devtool: ifMin(false, 'cheap-module-source-map'),
|
|
287
|
-
|
|
288
|
-
devServer: {
|
|
289
|
-
static: false,
|
|
290
|
-
historyApiFallback: {
|
|
291
|
-
disableDotRule: true,
|
|
292
|
-
},
|
|
293
|
-
hot: ifHmr(),
|
|
294
|
-
headers: {
|
|
295
|
-
'Access-Control-Allow-Origin': '*',
|
|
296
|
-
},
|
|
297
|
-
allowedHosts: 'all',
|
|
298
|
-
client: {
|
|
299
|
-
overlay: {
|
|
300
|
-
warnings: false,
|
|
301
|
-
errors: true,
|
|
302
|
-
},
|
|
303
|
-
},
|
|
304
|
-
server: ifHttps({
|
|
305
|
-
type: 'https',
|
|
306
|
-
options: {
|
|
307
|
-
cert: resolve(paths.root, HTTPS_CRT_FILE),
|
|
308
|
-
key: resolve(paths.root, HTTPS_KEY_FILE),
|
|
309
|
-
},
|
|
310
|
-
}),
|
|
311
|
-
},
|
|
312
|
-
|
|
313
|
-
optimization: {
|
|
314
|
-
// minimize: false,
|
|
315
|
-
removeEmptyChunks: true,
|
|
316
|
-
// moduleIds: 'deterministic', // todo: use instead of HashedModuleIdsPlugin
|
|
317
|
-
// chunkIds: 'named',
|
|
318
|
-
minimizer: ['...', new CssMinimizerPlugin()], // sourceMaps: true?
|
|
319
|
-
},
|
|
320
|
-
|
|
321
|
-
plugins: removeEmpty([
|
|
322
|
-
new webpack.ProgressPlugin(),
|
|
323
|
-
ifNolint(
|
|
324
|
-
false,
|
|
325
|
-
new ESLintPlugin({
|
|
326
|
-
extensions: moduleFileExtensions,
|
|
327
|
-
eslintPath: require.resolve('eslint'),
|
|
328
|
-
cwd: paths.app,
|
|
329
|
-
resolvePluginsRelativeTo: paths.app,
|
|
330
|
-
}),
|
|
331
|
-
),
|
|
332
|
-
ifMin(
|
|
333
|
-
new CleanWebpackPlugin({
|
|
334
|
-
// verbose: true,
|
|
335
|
-
}),
|
|
336
|
-
),
|
|
337
|
-
|
|
338
|
-
...appHtmlFiles.map(
|
|
339
|
-
(file) =>
|
|
340
|
-
new HtmlWebpackPlugin({
|
|
341
|
-
template: file,
|
|
342
|
-
filename: basename(file),
|
|
343
|
-
inject: false,
|
|
344
|
-
minify: false,
|
|
345
|
-
// ...ifMin({
|
|
346
|
-
// minify: {
|
|
347
|
-
// collapseWhitespace: true,
|
|
348
|
-
// removeComments: true,
|
|
349
|
-
// removeRedundantAttributes: true,
|
|
350
|
-
// removeScriptTypeAttributes: true,
|
|
351
|
-
// removeStyleLinkTypeAttributes: true,
|
|
352
|
-
// useShortDoctype: true,
|
|
353
|
-
// quoteCharacter: '"',
|
|
354
|
-
// minifyJS: true,
|
|
355
|
-
// minifyCSS: true,
|
|
356
|
-
// },
|
|
357
|
-
// }),
|
|
358
|
-
}),
|
|
359
|
-
),
|
|
360
|
-
|
|
361
|
-
new InterpolateHtmlPlugin(envVars.raw),
|
|
362
|
-
new webpack.DefinePlugin(envVars.stringified),
|
|
363
|
-
|
|
364
|
-
new ForkTsCheckerWebpackPlugin({
|
|
365
|
-
typescript: {
|
|
366
|
-
typescriptPath: require.resolve('typescript', {
|
|
367
|
-
paths: [paths.appNodeModules],
|
|
368
|
-
}),
|
|
369
|
-
configFile: paths.appTsConfig,
|
|
370
|
-
mode: 'write-references',
|
|
371
|
-
diagnosticOptions: {
|
|
372
|
-
syntactic: true,
|
|
373
|
-
semantic: true,
|
|
374
|
-
declaration: false,
|
|
375
|
-
global: false,
|
|
376
|
-
},
|
|
377
|
-
},
|
|
378
|
-
}),
|
|
379
|
-
|
|
380
|
-
ifHmr(new ReactRefreshWebpackPlugin()),
|
|
381
|
-
|
|
382
|
-
ifMin(
|
|
383
|
-
new MiniCssExtractPlugin({
|
|
384
|
-
filename: '[name]-[contenthash:16].css',
|
|
385
|
-
chunkFilename: '[name]-[contenthash:16].css',
|
|
386
|
-
ignoreOrder: true,
|
|
387
|
-
attributes: {
|
|
388
|
-
'data-widget': process.env.ELEMENT_ATTRIBUTE_DATA_WIDGET!,
|
|
389
|
-
},
|
|
390
|
-
}),
|
|
391
|
-
),
|
|
392
|
-
|
|
393
|
-
new webpack.IgnorePlugin({
|
|
394
|
-
resourceRegExp: /^\.\/locale$/,
|
|
395
|
-
contextRegExp: /moment$/,
|
|
396
|
-
}),
|
|
397
|
-
|
|
398
|
-
// eslint-disable-next-line import/no-named-as-default-member
|
|
399
|
-
ifMin(new webpack.ids.HashedModuleIdsPlugin()), // todo: remove?
|
|
400
|
-
|
|
401
|
-
ifMin() && ifCore()
|
|
402
|
-
? new CopyPlugin({
|
|
403
|
-
patterns: ['*.md', '*.html'],
|
|
404
|
-
})
|
|
405
|
-
: undefined,
|
|
406
|
-
|
|
407
|
-
ifMin() && ifAnalyze()
|
|
408
|
-
? new StatoscopeWebpackPlugin({
|
|
409
|
-
name: ifCore('tamaro-core', 'tamaro-customer-config'),
|
|
410
|
-
saveReportTo: 'reports/report.html',
|
|
411
|
-
saveStatsTo: 'reports/stats-[name]-[hash].json',
|
|
412
|
-
additionalStats: globSync('reports/*.json'),
|
|
413
|
-
open: false,
|
|
414
|
-
})
|
|
415
|
-
: undefined,
|
|
416
|
-
]),
|
|
417
|
-
|
|
418
|
-
infrastructureLogging: {
|
|
419
|
-
stream: process.stdout,
|
|
420
|
-
appendOnly: false,
|
|
421
|
-
},
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
// console.log(util.inspect(config, {showHidden: false, depth: null}))
|
|
425
|
-
|
|
426
|
-
return removeEmpty(config)
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
export default getWebpackConfig
|