create-template-bricks 0.0.0-stage → 1.0.0
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/README.md +85 -2
- package/bin/cli.js +403 -0
- package/package.json +49 -4
- package/templates/base/.babelrc +18 -0
- package/templates/base/.editorconfig +22 -0
- package/templates/base/.eslintrc.json +130 -0
- package/templates/base/AGENTS.md +49 -0
- package/templates/base/README.md +121 -0
- package/templates/base/gulpfile.js +46 -0
- package/templates/base/package.json +82 -0
- package/templates/base/postcss.config.mjs +6 -0
- package/templates/base/src/assets/css/vendor/.gitkeep +0 -0
- package/templates/base/src/assets/fonts/.gitkeep +0 -0
- package/templates/base/src/assets/img/Logo.svg +32 -0
- package/templates/base/src/assets/img/favicons/favicon.ico +0 -0
- package/templates/base/src/assets/img/sprite/cup-bronze.png +0 -0
- package/templates/base/src/assets/img/sprite/cup-bronze@2x.png +0 -0
- package/templates/base/src/assets/img/sprite.png +0 -0
- package/templates/base/src/assets/img/sprite@2x.png +0 -0
- package/templates/base/src/assets/img/svg-sprite/close.svg +3 -0
- package/templates/base/src/assets/img/svg-sprite/favorite.svg +3 -0
- package/templates/base/src/assets/img/svg-sprite/keyboard.svg +3 -0
- package/templates/base/src/assets/js/vendor/.gitkeep +0 -0
- package/templates/base/src/styles/core/base.scss +31 -0
- package/templates/base/src/styles/core/extends.scss +11 -0
- package/templates/base/src/styles/core/fonts.scss +0 -0
- package/templates/base/src/styles/core/index.scss +10 -0
- package/templates/base/src/styles/core/keyframes.scss +49 -0
- package/templates/base/src/styles/core/layouts/footer.scss +1 -0
- package/templates/base/src/styles/core/layouts/header/index.scss +1 -0
- package/templates/base/src/styles/core/layouts/index.scss +2 -0
- package/templates/base/src/styles/core/page.scss +16 -0
- package/templates/base/src/styles/core/typography.scss +1 -0
- package/templates/base/src/styles/core/ui/icons.scss +31 -0
- package/templates/base/src/styles/core/ui/index.scss +2 -0
- package/templates/base/src/styles/core/ui/scrollbar.scss +14 -0
- package/templates/base/src/styles/core/variables.scss +41 -0
- package/templates/base/src/styles/index.scss +1 -0
- package/templates/base/src/styles/plugins/functions.scss +0 -0
- package/templates/base/src/styles/plugins/media.scss +63 -0
- package/templates/base/src/styles/plugins/mixins.scss +31 -0
- package/templates/base/src/styles/plugins/sprite-mixin.scss +75 -0
- package/templates/base/src/styles/plugins/sprite.scss +154 -0
- package/templates/base/src/styles.scss +2 -0
- package/templates/base/src/tailwind.css +1 -0
- package/templates/base/src/tmplConfig.js +22 -0
- package/templates/base/tailwind.config.js +23 -0
- package/templates/base/tasks/archive.js +37 -0
- package/templates/base/tasks/clean.js +17 -0
- package/templates/base/tasks/config.js +98 -0
- package/templates/base/tasks/copy.js +53 -0
- package/templates/base/tasks/helper.js +31 -0
- package/templates/base/tasks/images/image-optimize.js +46 -0
- package/templates/base/tasks/images/index.js +27 -0
- package/templates/base/tasks/images/plugins/optimize-raster.js +44 -0
- package/templates/base/tasks/images/png-sprite.js +43 -0
- package/templates/base/tasks/template/data.js +28 -0
- package/templates/base/tasks/template/index.js +48 -0
- package/templates/base/tasks/template/plugins/generate-static-path.js +37 -0
- package/templates/base/tasks/template/plugins/nunjucks-relative-paths-includes.js +39 -0
- package/templates/base/tasks/template/plugins/nunjucks-relative-system-loader.js +28 -0
- package/templates/base/tasks/template/plugins/template-dependencies.js +246 -0
- package/templates/base/tasks/template/template.js +172 -0
- package/templates/base/tasks/watcher.js +233 -0
- package/templates/base/tasks/webpack/env.js +21 -0
- package/templates/base/tasks/webpack/plugins/build-status-plugin.js +74 -0
- package/templates/base/tasks/webpack/plugins/current-color-plugin.js +225 -0
- package/templates/base/tasks/webpack/plugins/removeFilesOnlyJs.js +28 -0
- package/templates/base/tasks/webpack/scripts.config.js +147 -0
- package/templates/base/tasks/webpack/styles.config.js +126 -0
- package/templates/base/tasks/webpack/svg-sprite.config.js +95 -0
- package/templates/base/tasks/webpack/watch.js +50 -0
- package/templates/base/tsconfig.json +20 -0
- package/templates/base/user.config.js +102 -0
- package/templates/base/webpack.config.js +9 -0
- package/templates/template-js/js/api/api.js +0 -0
- package/templates/template-js/js/core/core.js +56 -0
- package/templates/template-js/js/main.js +6 -0
- package/templates/template-js/js/modules/header.js +15 -0
- package/templates/template-js/js/modules/index.js +24 -0
- package/templates/template-js/js/services/index.js +1 -0
- package/templates/template-js/js/services/query-params.js +19 -0
- package/templates/template-js/js/styles.js +2 -0
- package/templates/template-js/js/ui/index.js +18 -0
- package/templates/template-js/js/utils/constants.js +0 -0
- package/templates/template-js/js/utils/create-factory.js +65 -0
- package/templates/template-js/js/utils/debounce.js +8 -0
- package/templates/template-js/js/utils/delay.js +4 -0
- package/templates/template-js/js/utils/is-platform.js +15 -0
- package/templates/template-js/js/utils/throttle.js +16 -0
- package/templates/template-mjml/emails/assets/images/address-btn.jpg +0 -0
- package/templates/template-mjml/emails/assets/images/address.jpg +0 -0
- package/templates/template-mjml/emails/assets/images/banner.jpg +0 -0
- package/templates/template-mjml/emails/assets/images/close.png +0 -0
- package/templates/template-mjml/emails/assets/images/confirm-btn.jpg +0 -0
- package/templates/template-mjml/emails/assets/images/facebook.png +0 -0
- package/templates/template-mjml/emails/assets/images/forgot.jpg +0 -0
- package/templates/template-mjml/emails/assets/images/icon-info.png +0 -0
- package/templates/template-mjml/emails/assets/images/img-send.jpg +0 -0
- package/templates/template-mjml/emails/assets/images/instagram.png +0 -0
- package/templates/template-mjml/emails/assets/images/logo.png +0 -0
- package/templates/template-mjml/emails/assets/images/reset-btn.jpg +0 -0
- package/templates/template-mjml/emails/assets/images/twitter.png +0 -0
- package/templates/template-mjml/emails/pages/address.mjml +55 -0
- package/templates/template-mjml/emails/pages/confirm-resend.mjml +63 -0
- package/templates/template-mjml/emails/pages/confirm.mjml +44 -0
- package/templates/template-mjml/emails/pages/forgot-password.mjml +65 -0
- package/templates/template-mjml/emails/shared/ui/head/fonts.mjml +211 -0
- package/templates/template-mjml/emails/shared/ui/head/index.mjml +146 -0
- package/templates/template-mjml/emails/widgets/footer/ui/index.mjml +12 -0
- package/templates/template-nunjucks/templates/layouts/base.njk +23 -0
- package/templates/template-nunjucks/templates/pages/index.njk +9 -0
- package/templates/template-nunjucks/templates/shared/ui/head/data.json +8 -0
- package/templates/template-nunjucks/templates/shared/ui/head/index.njk +13 -0
- package/templates/template-nunjucks/templates/shared/ui/icon/index.njk +5 -0
- package/templates/template-nunjucks/templates/widgets/footer/index.njk +5 -0
- package/templates/template-nunjucks/templates/widgets/footer/model/data.json +4 -0
- package/templates/template-nunjucks/templates/widgets/footer/ui/index.njk +7 -0
- package/templates/template-nunjucks/templates/widgets/home-hero/index.njk +1 -0
- package/templates/template-nunjucks/templates/widgets/home-hero/ui/index.njk +9 -0
- package/templates/template-pug/templates/layouts/base.pug +19 -0
- package/templates/template-pug/templates/pages/index.pug +12 -0
- package/templates/template-pug/templates/shared/lib/blocks.pug +21 -0
- package/templates/template-pug/templates/shared/ui/head/data.json +8 -0
- package/templates/template-pug/templates/shared/ui/head/index.pug +10 -0
- package/templates/template-pug/templates/shared/ui/icon/index.pug +3 -0
- package/templates/template-pug/templates/widgets/footer/index.pug +1 -0
- package/templates/template-pug/templates/widgets/footer/model/data.json +4 -0
- package/templates/template-pug/templates/widgets/footer/ui/index.pug +4 -0
- package/templates/template-pug/templates/widgets/home-hero/index.pug +1 -0
- package/templates/template-pug/templates/widgets/home-hero/ui/index.pug +6 -0
- package/templates/template-ts/ts/api/api.ts +0 -0
- package/templates/template-ts/ts/core/core.ts +66 -0
- package/templates/template-ts/ts/interfaces/factory.ts +5 -0
- package/templates/template-ts/ts/main.ts +6 -0
- package/templates/template-ts/ts/modules/header.ts +17 -0
- package/templates/template-ts/ts/modules/index.ts +26 -0
- package/templates/template-ts/ts/services/index.ts +2 -0
- package/templates/template-ts/ts/services/query-params.ts +23 -0
- package/templates/template-ts/ts/styles.ts +2 -0
- package/templates/template-ts/ts/ui/index.ts +23 -0
- package/templates/template-ts/ts/utils/constants.ts +0 -0
- package/templates/template-ts/ts/utils/create-factory.ts +91 -0
- package/templates/template-ts/ts/utils/debounce.ts +10 -0
- package/templates/template-ts/ts/utils/delay.ts +5 -0
- package/templates/template-ts/ts/utils/is-platform.ts +21 -0
- package/templates/template-ts/ts/utils/throttle.ts +19 -0
- package/templates/template-twig/templates/layouts/base.html.twig +26 -0
- package/templates/template-twig/templates/pages/index.html.twig +8 -0
- package/templates/template-twig/templates/shared/ui/head/data.json +8 -0
- package/templates/template-twig/templates/shared/ui/head/index.html.twig +11 -0
- package/templates/template-twig/templates/shared/ui/icon/index.html.twig +21 -0
- package/templates/template-twig/templates/widgets/footer/index.html.twig +1 -0
- package/templates/template-twig/templates/widgets/footer/model/data.json +4 -0
- package/templates/template-twig/templates/widgets/footer/ui/index.html.twig +5 -0
- package/templates/template-twig/templates/widgets/home-hero/index.html.twig +1 -0
- package/templates/template-twig/templates/widgets/home-hero/ui/index.html.twig +9 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
4
|
+
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
|
|
5
|
+
import ESLintPlugin from 'eslint-webpack-plugin';
|
|
6
|
+
import BuildStatusPlugin from './plugins/build-status-plugin.js';
|
|
7
|
+
import { isProduction, webpackPath } from '../config.js';
|
|
8
|
+
import userConfig from '../../user.config.js';
|
|
9
|
+
import envModule from './env.js';
|
|
10
|
+
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const { sourceMap, devtool } = envModule;
|
|
12
|
+
|
|
13
|
+
const rules = [
|
|
14
|
+
{
|
|
15
|
+
test: /\.s[ac]ss$/i,
|
|
16
|
+
use: [
|
|
17
|
+
{
|
|
18
|
+
loader: MiniCssExtractPlugin.loader
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
loader: 'css-loader',
|
|
22
|
+
options: {
|
|
23
|
+
sourceMap
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
loader: 'postcss-loader',
|
|
28
|
+
options: {
|
|
29
|
+
sourceMap
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
loader: 'sass-loader',
|
|
34
|
+
options: {
|
|
35
|
+
sourceMap,
|
|
36
|
+
sassOptions: {
|
|
37
|
+
quietDeps: true
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
test: /\.css$/i,
|
|
45
|
+
use: [
|
|
46
|
+
{
|
|
47
|
+
loader: MiniCssExtractPlugin.loader
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
loader: 'css-loader',
|
|
51
|
+
options: {
|
|
52
|
+
sourceMap
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
loader: 'postcss-loader',
|
|
57
|
+
options: {
|
|
58
|
+
sourceMap
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
if (userConfig.typeScript) {
|
|
66
|
+
rules.push({
|
|
67
|
+
test: /\.ts?$/,
|
|
68
|
+
exclude: /node_modules/,
|
|
69
|
+
use: 'ts-loader'
|
|
70
|
+
});
|
|
71
|
+
} else {
|
|
72
|
+
rules.push({
|
|
73
|
+
test: /\.js$/,
|
|
74
|
+
exclude: /node_modules/,
|
|
75
|
+
use: [
|
|
76
|
+
{
|
|
77
|
+
loader: 'babel-loader',
|
|
78
|
+
options: {
|
|
79
|
+
presets: ['@babel/preset-env']
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const scriptsConfig = {
|
|
87
|
+
mode: isProduction ? 'production' : 'development',
|
|
88
|
+
devtool,
|
|
89
|
+
entry: webpackPath.entry,
|
|
90
|
+
performance: {
|
|
91
|
+
hints: false
|
|
92
|
+
},
|
|
93
|
+
stats: {
|
|
94
|
+
all: false,
|
|
95
|
+
errors: true,
|
|
96
|
+
warnings: true,
|
|
97
|
+
errorsCount: true,
|
|
98
|
+
timings: true,
|
|
99
|
+
errorDetails: false
|
|
100
|
+
},
|
|
101
|
+
infrastructureLogging: {
|
|
102
|
+
level: 'none'
|
|
103
|
+
},
|
|
104
|
+
module: {
|
|
105
|
+
rules
|
|
106
|
+
},
|
|
107
|
+
plugins: [
|
|
108
|
+
new BuildStatusPlugin({
|
|
109
|
+
name: 'Scripts',
|
|
110
|
+
showWarnings: true
|
|
111
|
+
}),
|
|
112
|
+
new MiniCssExtractPlugin({
|
|
113
|
+
filename: '../css/[name].css'
|
|
114
|
+
}),
|
|
115
|
+
new ESLintPlugin()
|
|
116
|
+
],
|
|
117
|
+
optimization: {
|
|
118
|
+
splitChunks: {
|
|
119
|
+
cacheGroups: {
|
|
120
|
+
vendor: {
|
|
121
|
+
chunks: 'initial',
|
|
122
|
+
test: /node_modules/,
|
|
123
|
+
name: 'vendor',
|
|
124
|
+
enforce: true
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
minimize: isProduction,
|
|
129
|
+
minimizer: isProduction ? [
|
|
130
|
+
'...',
|
|
131
|
+
new CssMinimizerPlugin()
|
|
132
|
+
] : []
|
|
133
|
+
},
|
|
134
|
+
output: {
|
|
135
|
+
path: path.resolve(dirname, webpackPath.output),
|
|
136
|
+
publicPath: webpackPath.output,
|
|
137
|
+
filename: '[name].js'
|
|
138
|
+
},
|
|
139
|
+
resolve: {
|
|
140
|
+
extensions: ['.ts', '.tsx', '.js'],
|
|
141
|
+
alias: {}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export {
|
|
146
|
+
scriptsConfig
|
|
147
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
4
|
+
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
|
|
5
|
+
import { isProduction, stylesPath } from '../config.js';
|
|
6
|
+
import RemoveFilesOnlyJsPlugin from './plugins/removeFilesOnlyJs.js';
|
|
7
|
+
import userConfig from '../../user.config.js';
|
|
8
|
+
import envModule from './env.js';
|
|
9
|
+
import BuildStatusPlugin from './plugins/build-status-plugin.js';
|
|
10
|
+
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const { sourceMap, devtool } = envModule;
|
|
12
|
+
|
|
13
|
+
export const stylesConfig = {
|
|
14
|
+
mode: isProduction ? 'production' : 'development',
|
|
15
|
+
devtool,
|
|
16
|
+
performance: {
|
|
17
|
+
hints: false
|
|
18
|
+
},
|
|
19
|
+
stats: {
|
|
20
|
+
all: false,
|
|
21
|
+
errors: true,
|
|
22
|
+
warnings: true,
|
|
23
|
+
errorsCount: true,
|
|
24
|
+
timings: true,
|
|
25
|
+
errorDetails: false
|
|
26
|
+
},
|
|
27
|
+
infrastructureLogging: {
|
|
28
|
+
level: 'none'
|
|
29
|
+
},
|
|
30
|
+
entry: stylesPath.entry,
|
|
31
|
+
output: {
|
|
32
|
+
path: path.resolve(dirname, stylesPath.dist),
|
|
33
|
+
publicPath: stylesPath.dist,
|
|
34
|
+
filename: '[name].js'
|
|
35
|
+
},
|
|
36
|
+
module: {
|
|
37
|
+
rules: [
|
|
38
|
+
{
|
|
39
|
+
test: /\.s[ac]ss$/i,
|
|
40
|
+
use: [
|
|
41
|
+
{
|
|
42
|
+
loader: MiniCssExtractPlugin.loader
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
loader: 'css-loader',
|
|
46
|
+
options: {
|
|
47
|
+
url: false,
|
|
48
|
+
sourceMap
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
loader: 'postcss-loader',
|
|
53
|
+
options: {
|
|
54
|
+
sourceMap
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
loader: 'sass-loader',
|
|
59
|
+
options: {
|
|
60
|
+
sourceMap,
|
|
61
|
+
sassOptions: {
|
|
62
|
+
quietDeps: true
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
test: /\.css$/i,
|
|
70
|
+
use: [
|
|
71
|
+
{
|
|
72
|
+
loader: MiniCssExtractPlugin.loader
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
loader: 'css-loader',
|
|
76
|
+
options: {
|
|
77
|
+
url: false,
|
|
78
|
+
sourceMap
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
loader: 'postcss-loader',
|
|
83
|
+
options: {
|
|
84
|
+
sourceMap
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
test: /\.(png|jpe?g|gif|svg)$/i,
|
|
91
|
+
type: 'asset/resource',
|
|
92
|
+
generator: {
|
|
93
|
+
filename: '../img/content/[name][ext]',
|
|
94
|
+
publicPath: ''
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
test: /\.(woff2?|eot|ttf|otf)$/i,
|
|
99
|
+
type: 'asset/resource',
|
|
100
|
+
generator: {
|
|
101
|
+
filename: '../fonts/[name][ext]',
|
|
102
|
+
publicPath: ''
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
plugins: [
|
|
108
|
+
new BuildStatusPlugin({
|
|
109
|
+
name: 'Styles',
|
|
110
|
+
showWarnings: true
|
|
111
|
+
}),
|
|
112
|
+
new MiniCssExtractPlugin({
|
|
113
|
+
filename: '../css/[name].css'
|
|
114
|
+
}),
|
|
115
|
+
new RemoveFilesOnlyJsPlugin({
|
|
116
|
+
test: new RegExp(`^${userConfig.styleFileName}\\.js(\\.map)?$`)
|
|
117
|
+
})
|
|
118
|
+
],
|
|
119
|
+
optimization: {
|
|
120
|
+
minimize: isProduction,
|
|
121
|
+
minimizer: isProduction ? [
|
|
122
|
+
'...',
|
|
123
|
+
new CssMinimizerPlugin()
|
|
124
|
+
] : []
|
|
125
|
+
}
|
|
126
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import SVGSpritemapPlugin from 'svg-spritemap-webpack-plugin';
|
|
3
|
+
import { imagesPath } from '../config.js';
|
|
4
|
+
import currentColorPlugin from './plugins/current-color-plugin.js';
|
|
5
|
+
import BuildStatusPlugin from './plugins/build-status-plugin.js';
|
|
6
|
+
|
|
7
|
+
export const svgSpriteConfig = {
|
|
8
|
+
entry: {},
|
|
9
|
+
output: {
|
|
10
|
+
path: path.resolve(
|
|
11
|
+
import.meta.dirname,
|
|
12
|
+
`../../${imagesPath.dist}`
|
|
13
|
+
)
|
|
14
|
+
},
|
|
15
|
+
performance: {
|
|
16
|
+
hints: false
|
|
17
|
+
},
|
|
18
|
+
stats: {
|
|
19
|
+
all: false,
|
|
20
|
+
errors: true,
|
|
21
|
+
warnings: true,
|
|
22
|
+
errorsCount: true,
|
|
23
|
+
timings: true,
|
|
24
|
+
errorDetails: false
|
|
25
|
+
},
|
|
26
|
+
infrastructureLogging: {
|
|
27
|
+
level: 'none'
|
|
28
|
+
},
|
|
29
|
+
plugins: [
|
|
30
|
+
new BuildStatusPlugin({
|
|
31
|
+
name: 'SVG sprite',
|
|
32
|
+
showWarnings: true
|
|
33
|
+
}),
|
|
34
|
+
new SVGSpritemapPlugin(
|
|
35
|
+
path.resolve(
|
|
36
|
+
import.meta.dirname,
|
|
37
|
+
`../../${imagesPath.svgSpriteFolder}/**/*.svg`
|
|
38
|
+
),
|
|
39
|
+
{
|
|
40
|
+
output: {
|
|
41
|
+
filename: 'symbols.svg',
|
|
42
|
+
|
|
43
|
+
chunk: {
|
|
44
|
+
keep: false
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
svg: {
|
|
48
|
+
sizes: false
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
svgo: {
|
|
52
|
+
plugins: [
|
|
53
|
+
{
|
|
54
|
+
name: 'preset-default',
|
|
55
|
+
params: {
|
|
56
|
+
overrides: {
|
|
57
|
+
|
|
58
|
+
/*
|
|
59
|
+
* Do not shorten IDs to a, b, c.
|
|
60
|
+
* Otherwise clipPaths from different
|
|
61
|
+
* icons can conflict in the sprite.
|
|
62
|
+
*/
|
|
63
|
+
cleanupIds: false,
|
|
64
|
+
|
|
65
|
+
/*
|
|
66
|
+
* Do not remove <symbol> nodes without
|
|
67
|
+
* internal ID references (icons without
|
|
68
|
+
* clipPath/mask). SVGO v4 treats them
|
|
69
|
+
* as "hidden" and drops them from the
|
|
70
|
+
* sprite.
|
|
71
|
+
*/
|
|
72
|
+
removeHiddenElems: false
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
'removeDimensions',
|
|
77
|
+
currentColorPlugin
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
sprite: {
|
|
83
|
+
prefix: 'icon-',
|
|
84
|
+
generate: {
|
|
85
|
+
symbol: true,
|
|
86
|
+
title: false,
|
|
87
|
+
dimensions: false,
|
|
88
|
+
use: false,
|
|
89
|
+
view: false
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
]
|
|
95
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import gulp from 'gulp';
|
|
2
|
+
import webpack from 'webpack';
|
|
3
|
+
import webpackConfig from '../../webpack.config.js';
|
|
4
|
+
import userConfig from '../../user.config.js';
|
|
5
|
+
|
|
6
|
+
const watchWebpack = done => {
|
|
7
|
+
const compiler = webpack(webpackConfig.map(config => ({
|
|
8
|
+
...config,
|
|
9
|
+
mode: 'development'
|
|
10
|
+
})));
|
|
11
|
+
|
|
12
|
+
const rebuildWebpack = complete => {
|
|
13
|
+
compiler.run((error, stats) => {
|
|
14
|
+
if (error) {
|
|
15
|
+
console.error(error);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (stats) {
|
|
19
|
+
const details = stats.toString({
|
|
20
|
+
all: false,
|
|
21
|
+
errors: true,
|
|
22
|
+
warnings: true,
|
|
23
|
+
colors: Boolean(process.stdout.isTTY)
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (details) {
|
|
27
|
+
console.log(details);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Keep watching after errors so the next edit can fix the build.
|
|
32
|
+
complete();
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// npm start completes the standalone build before reaching this task.
|
|
37
|
+
gulp.watch([
|
|
38
|
+
`${userConfig.sourceFolder}/**/*`,
|
|
39
|
+
'tsconfig*.json',
|
|
40
|
+
'tailwind.config.js',
|
|
41
|
+
'postcss.config.mjs'
|
|
42
|
+
], {
|
|
43
|
+
ignoreInitial: true,
|
|
44
|
+
delay: 100
|
|
45
|
+
}, rebuildWebpack);
|
|
46
|
+
|
|
47
|
+
done();
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default watchWebpack;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es6",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": [
|
|
7
|
+
"esnext",
|
|
8
|
+
"dom"
|
|
9
|
+
],
|
|
10
|
+
"outDir": "./.cache/ts",
|
|
11
|
+
"declaration": true,
|
|
12
|
+
"sourceMap": true,
|
|
13
|
+
"esModuleInterop": true,
|
|
14
|
+
"experimentalDecorators": true,
|
|
15
|
+
"emitDecoratorMetadata": true
|
|
16
|
+
},
|
|
17
|
+
"exclude": [
|
|
18
|
+
"node_modules"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global build environment configuration
|
|
3
|
+
* @typedef {Object} userConfig
|
|
4
|
+
*
|
|
5
|
+
* @property {string|null} projectVersion
|
|
6
|
+
* Project version.
|
|
7
|
+
* If `null` — default version ("1.0").
|
|
8
|
+
*
|
|
9
|
+
* @property {boolean} backupBuild
|
|
10
|
+
* Create backupBuild copies before build.
|
|
11
|
+
*
|
|
12
|
+
* @property {boolean} emailsBuild
|
|
13
|
+
* Enable emails build pipeline.
|
|
14
|
+
*
|
|
15
|
+
* @property {string} folderBuild
|
|
16
|
+
* Output build folder name.
|
|
17
|
+
*
|
|
18
|
+
* @property {string} serverIndexPage
|
|
19
|
+
* Entry HTML file for dev server.
|
|
20
|
+
*
|
|
21
|
+
* @property {boolean} optimizeImages
|
|
22
|
+
* Enable image optimization.
|
|
23
|
+
*
|
|
24
|
+
* @property {boolean} optimizePng
|
|
25
|
+
* Enable PNG optimization.
|
|
26
|
+
*
|
|
27
|
+
* @property {boolean} spritePng
|
|
28
|
+
* Generate PNG sprites.
|
|
29
|
+
*
|
|
30
|
+
* @property {boolean} typeScript
|
|
31
|
+
* Enable TypeScript support.
|
|
32
|
+
*
|
|
33
|
+
* @property {boolean} sourcemaps
|
|
34
|
+
* Generate source maps.
|
|
35
|
+
*
|
|
36
|
+
* @property {string} sourceFolder
|
|
37
|
+
* Source directory name.
|
|
38
|
+
*
|
|
39
|
+
* @property {string} assetsBuild
|
|
40
|
+
* Assets folder path.
|
|
41
|
+
*
|
|
42
|
+
* @property {string} styleFileName
|
|
43
|
+
* Base name for compiled CSS file.
|
|
44
|
+
*
|
|
45
|
+
* @property {string} imageFolderName
|
|
46
|
+
* Images folder name.
|
|
47
|
+
*
|
|
48
|
+
* @property {'pug' | 'nunjucks' | 'twig'} templateEngine
|
|
49
|
+
* Template preprocessor.
|
|
50
|
+
*
|
|
51
|
+
* @property {Object} templateLocals
|
|
52
|
+
* Locals passed to templates.
|
|
53
|
+
*
|
|
54
|
+
* @property {string} templateLocals.version
|
|
55
|
+
* Project version for templates.
|
|
56
|
+
*
|
|
57
|
+
* @property {boolean} templateLocals.symbolsInject
|
|
58
|
+
* Inject SVG symbols automatically.
|
|
59
|
+
*
|
|
60
|
+
* @property {string} templateLocals.pathPrefix
|
|
61
|
+
* Static assets path prefix.
|
|
62
|
+
*
|
|
63
|
+
* @property {boolean} htmlMinify
|
|
64
|
+
* Minify HTML output.
|
|
65
|
+
*
|
|
66
|
+
* @property {Object} prettify
|
|
67
|
+
* HTML prettify options.
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
/** @type {userConfig} */
|
|
71
|
+
const userConfig = {
|
|
72
|
+
projectVersion: null,
|
|
73
|
+
backupBuild: false,
|
|
74
|
+
serverIndexPage: 'index.html',
|
|
75
|
+
optimizeImages: true,
|
|
76
|
+
optimizePng: true,
|
|
77
|
+
spritePng: false,
|
|
78
|
+
emailsBuild: false,
|
|
79
|
+
folderBuild: 'build',
|
|
80
|
+
assetsBuild: 'build/assets',
|
|
81
|
+
typeScript: false,
|
|
82
|
+
sourcemaps: false,
|
|
83
|
+
sourceFolder: 'src',
|
|
84
|
+
styleFileName: 'styles',
|
|
85
|
+
imageFolderName: 'img',
|
|
86
|
+
templateEngine: 'pug',
|
|
87
|
+
templateLocals: {
|
|
88
|
+
version: '',
|
|
89
|
+
symbolsInject: false,
|
|
90
|
+
pathPrefix: '__static__'
|
|
91
|
+
},
|
|
92
|
+
htmlMinify: false,
|
|
93
|
+
prettify: {
|
|
94
|
+
'indent_char': ' ',
|
|
95
|
+
'indent_size': 4,
|
|
96
|
+
'indent_level': 1,
|
|
97
|
+
'preserve_newlines': true,
|
|
98
|
+
'max_preserve_newlines': 1
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export default userConfig;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { scriptsConfig } from './tasks/webpack/scripts.config.js';
|
|
2
|
+
import { stylesConfig } from './tasks/webpack/styles.config.js';
|
|
3
|
+
import { svgSpriteConfig } from './tasks/webpack/svg-sprite.config.js';
|
|
4
|
+
|
|
5
|
+
export default [
|
|
6
|
+
scriptsConfig,
|
|
7
|
+
stylesConfig,
|
|
8
|
+
svgSpriteConfig
|
|
9
|
+
];
|
|
File without changes
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import uiModules from '../ui/index.js';
|
|
2
|
+
import { isPlatformClasses } from '../utils/is-platform.js';
|
|
3
|
+
|
|
4
|
+
export class BaseApp {
|
|
5
|
+
constructor(createModules) {
|
|
6
|
+
this.createModules = createModules;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
onStart = () => {
|
|
10
|
+
this.init();
|
|
11
|
+
this.afterLoad();
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
init() {
|
|
15
|
+
isPlatformClasses();
|
|
16
|
+
this.ui = uiModules();
|
|
17
|
+
this.modules = this.createModules();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
destroy() {
|
|
21
|
+
if (this.ui && typeof this.ui.destroy === 'function') {
|
|
22
|
+
this.ui.destroy();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (this.modules && typeof this.modules.destroy === 'function') {
|
|
26
|
+
this.modules.destroy();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
this.ui = null;
|
|
30
|
+
this.modules = null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
afterLoad() {
|
|
34
|
+
if (document.readyState === 'complete') {
|
|
35
|
+
this.markLoaded();
|
|
36
|
+
} else {
|
|
37
|
+
window.addEventListener('load', this.markLoaded, { once: true });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
markLoaded = () => {
|
|
42
|
+
document.body?.classList.add('load');
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function bootstrapApp(AppClass, createModules) {
|
|
47
|
+
const app = new AppClass(createModules);
|
|
48
|
+
|
|
49
|
+
if (document.readyState === 'loading') {
|
|
50
|
+
document.addEventListener('DOMContentLoaded', app.onStart, { once: true });
|
|
51
|
+
} else {
|
|
52
|
+
app.onStart();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return app;
|
|
56
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import createFactory from '../utils/create-factory.js';
|
|
2
|
+
import Header from './header.js';
|
|
3
|
+
const createModules = () => {
|
|
4
|
+
const factory = createFactory();
|
|
5
|
+
|
|
6
|
+
return {
|
|
7
|
+
onInit: () => {
|
|
8
|
+
factory.create(Header);
|
|
9
|
+
},
|
|
10
|
+
destroy: () => {
|
|
11
|
+
factory.destroy();
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const modulesComponent = () => {
|
|
17
|
+
const factory = createModules();
|
|
18
|
+
|
|
19
|
+
factory.onInit();
|
|
20
|
+
|
|
21
|
+
return factory;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default modulesComponent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createQueryString } from './query-params.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const createQueryString = (params) => {
|
|
2
|
+
const searchParams = new URLSearchParams();
|
|
3
|
+
|
|
4
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
5
|
+
const values = Array.isArray(value) ? value : [value];
|
|
6
|
+
|
|
7
|
+
values.forEach((item) => {
|
|
8
|
+
if (item === null || item === undefined || item === '') {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
searchParams.append(key, String(item));
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const queryString = searchParams.toString();
|
|
17
|
+
|
|
18
|
+
return queryString ? `?${queryString}` : '';
|
|
19
|
+
};
|