@sumotto/configs 0.0.1
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/.editorconfig +36 -0
- package/helpers/webpack.js +185 -0
- package/package.json +47 -0
- package/wp/phpcs.xml +60 -0
- package/wp/tsconfig.json +36 -0
- package/wp/webpack.blocks.config.js +37 -0
- package/wp/webpack.theme.config.js +202 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# https://github.com/WordPress/gutenberg/blob/HEAD/.editorconfig
|
|
2
|
+
|
|
3
|
+
# This file is for unifying the coding style for different editors and IDEs
|
|
4
|
+
# editorconfig.org
|
|
5
|
+
|
|
6
|
+
# WordPress Coding Standards
|
|
7
|
+
# https://make.wordpress.org/core/handbook/coding-standards/
|
|
8
|
+
|
|
9
|
+
# This file is for unifying the coding style for different editors and IDEs
|
|
10
|
+
# editorconfig.org
|
|
11
|
+
|
|
12
|
+
# WordPress Coding Standards
|
|
13
|
+
# https://make.wordpress.org/core/handbook/coding-standards/
|
|
14
|
+
|
|
15
|
+
root = true
|
|
16
|
+
|
|
17
|
+
[*]
|
|
18
|
+
charset = utf-8
|
|
19
|
+
end_of_line = lf
|
|
20
|
+
insert_final_newline = true
|
|
21
|
+
trim_trailing_whitespace = true
|
|
22
|
+
indent_style = tab
|
|
23
|
+
|
|
24
|
+
[*.{yml,yaml}]
|
|
25
|
+
indent_style = space
|
|
26
|
+
indent_size = 2
|
|
27
|
+
|
|
28
|
+
[*.{gradle,java,kt}]
|
|
29
|
+
indent_style = space
|
|
30
|
+
|
|
31
|
+
[packages/react-native-*/**.xml]
|
|
32
|
+
indent_style = space
|
|
33
|
+
|
|
34
|
+
# Here we digress from WP because such JSON is generated by ACF and it is better not to fight with it
|
|
35
|
+
[acf-json/*.json]
|
|
36
|
+
indent_style = space
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
const path = require( 'node:path' );
|
|
2
|
+
const glob = require( 'glob' );
|
|
3
|
+
const fs = require( 'fs' );
|
|
4
|
+
|
|
5
|
+
require( 'dotenv' ).config( {
|
|
6
|
+
path: [
|
|
7
|
+
path.resolve( process.cwd(), '.env.local' ),
|
|
8
|
+
path.resolve( process.cwd(), '.env' ),
|
|
9
|
+
path.resolve( process.cwd(), '../../../.env.local' ),
|
|
10
|
+
path.resolve( process.cwd(), '../../../.env' ),
|
|
11
|
+
],
|
|
12
|
+
} );
|
|
13
|
+
|
|
14
|
+
const [
|
|
15
|
+
defaultConfigWP,
|
|
16
|
+
modulesConfigWP,
|
|
17
|
+
] = require( '@wordpress/scripts/config/webpack.config.js' );
|
|
18
|
+
|
|
19
|
+
function getEntryName( entryPath ) {
|
|
20
|
+
const entryData = path.parse( entryPath );
|
|
21
|
+
return path
|
|
22
|
+
.normalize(
|
|
23
|
+
path.join(
|
|
24
|
+
path.relative(
|
|
25
|
+
path.join( process.cwd(), 'src' ),
|
|
26
|
+
entryData.dir
|
|
27
|
+
),
|
|
28
|
+
entryData.name
|
|
29
|
+
)
|
|
30
|
+
)
|
|
31
|
+
.replaceAll( '\\', '/' );
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getEntries( globPattern ) {
|
|
35
|
+
return glob
|
|
36
|
+
.sync( globPattern, {
|
|
37
|
+
absolute: true,
|
|
38
|
+
cwd: process.cwd(),
|
|
39
|
+
} )
|
|
40
|
+
.reduce( function ( entries, entryPath ) {
|
|
41
|
+
if ( fs.statSync( entryPath ).size > 0 ) {
|
|
42
|
+
entries[ getEntryName( entryPath ) ] = entryPath;
|
|
43
|
+
}
|
|
44
|
+
return entries;
|
|
45
|
+
}, {} );
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports.defaultConfigWP = defaultConfigWP;
|
|
49
|
+
module.exports.modulesConfigWP = modulesConfigWP;
|
|
50
|
+
|
|
51
|
+
module.exports.Config = class {
|
|
52
|
+
constructor( config, name, port = 'auto' ) {
|
|
53
|
+
this.config = config;
|
|
54
|
+
this.config.name = name;
|
|
55
|
+
|
|
56
|
+
if ( config.devServer ) {
|
|
57
|
+
// noinspection JSUnusedGlobalSymbols
|
|
58
|
+
this.config.devServer = {
|
|
59
|
+
...config.devServer,
|
|
60
|
+
port,
|
|
61
|
+
allowedHosts: 'all',
|
|
62
|
+
client: {
|
|
63
|
+
...config.devServer?.client,
|
|
64
|
+
overlay: {
|
|
65
|
+
...config.devServer?.client?.overlay,
|
|
66
|
+
runtimeErrors: ( error ) => {
|
|
67
|
+
return (
|
|
68
|
+
error?.message !==
|
|
69
|
+
'ResizeObserver loop completed with undelivered notifications.'
|
|
70
|
+
);
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
watchFiles: [ 'src/scripts/modules/*' ],
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
this.config.optimization = {
|
|
78
|
+
...config.optimization,
|
|
79
|
+
runtimeChunk: 'single',
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
get() {
|
|
85
|
+
return this.config;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
resetEntries() {
|
|
89
|
+
this.config.entry = {};
|
|
90
|
+
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
addEntries( globPattern ) {
|
|
95
|
+
if ( typeof this.config.entry === 'function' ) {
|
|
96
|
+
this.config.entry = {
|
|
97
|
+
...this.config.entry(),
|
|
98
|
+
...getEntries( globPattern ),
|
|
99
|
+
};
|
|
100
|
+
} else {
|
|
101
|
+
this.config.entry = {
|
|
102
|
+
...this.config.entry,
|
|
103
|
+
...getEntries( globPattern ),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
changeRule( test, callBack ) {
|
|
111
|
+
this.config.module.rules.forEach( ( rule, index ) => {
|
|
112
|
+
if ( test === rule.test.toString() ) {
|
|
113
|
+
callBack( rule, index );
|
|
114
|
+
}
|
|
115
|
+
} );
|
|
116
|
+
|
|
117
|
+
return this;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
removePlugin( pluginClass ) {
|
|
121
|
+
this.config.plugins.forEach( ( plugin, number ) => {
|
|
122
|
+
if ( plugin instanceof pluginClass ) {
|
|
123
|
+
this.config.plugins.splice( number, 1 );
|
|
124
|
+
}
|
|
125
|
+
} );
|
|
126
|
+
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
addPlugin( plugin, position = 'after' ) {
|
|
131
|
+
if ( typeof this.config.plugins === 'undefined' ) {
|
|
132
|
+
this.config.plugins = [];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if ( 'before' === position ) {
|
|
136
|
+
this.config.plugins.unshift( plugin );
|
|
137
|
+
} else {
|
|
138
|
+
this.config.plugins.push( plugin );
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return this;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
replacePlugin( newPlugin ) {
|
|
145
|
+
this.config.plugins.forEach( ( plugin, index ) => {
|
|
146
|
+
if ( plugin instanceof newPlugin.constructor ) {
|
|
147
|
+
this.config.plugins[ index ] = newPlugin;
|
|
148
|
+
}
|
|
149
|
+
} );
|
|
150
|
+
|
|
151
|
+
return this;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
addMinimizer( minimizer ) {
|
|
155
|
+
if ( typeof this.config.optimization === 'undefined' ) {
|
|
156
|
+
this.config.optimization = {};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if ( typeof this.config.optimization.minimizer === 'undefined' ) {
|
|
160
|
+
this.config.optimization.minimizer = [];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
this.config.optimization.minimizer.push( minimizer );
|
|
164
|
+
|
|
165
|
+
return this;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
addWatch( globPattern ) {
|
|
169
|
+
if ( this.config.devServer ) {
|
|
170
|
+
this.config.devServer = {
|
|
171
|
+
...this.config.devServer,
|
|
172
|
+
watchFiles: [
|
|
173
|
+
...this.config.devServer?.watchFiles,
|
|
174
|
+
globPattern,
|
|
175
|
+
],
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return this;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
static hasDevServer( config ) {
|
|
183
|
+
return !! config.devServer;
|
|
184
|
+
}
|
|
185
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sumotto/configs",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Configs for my work",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"release": "np --yolo"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/SumoTTo/configs.git"
|
|
11
|
+
},
|
|
12
|
+
"author": {
|
|
13
|
+
"name": "Sigalin Kirill",
|
|
14
|
+
"email": "sumotto@yandex.ru"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/SumoTTo/configs/issues"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://github.com/SumoTTo/configs#readme",
|
|
21
|
+
"type": "module",
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"np": "^10.0.5"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@wordpress/scripts": "^27.9.0",
|
|
27
|
+
"clean-webpack-plugin": "^4.0.0",
|
|
28
|
+
"copy-webpack-plugin": "^12.0.2",
|
|
29
|
+
"dotenv": "^16.4.5",
|
|
30
|
+
"glob": "^10.4.1",
|
|
31
|
+
"image-minimizer-webpack-plugin": "^4.0.1",
|
|
32
|
+
"mini-css-extract-plugin": "^2.9.0",
|
|
33
|
+
"rtlcss-webpack-plugin": "^4.0.7",
|
|
34
|
+
"sharp": "^0.33.4",
|
|
35
|
+
"svgo": "^3.3.2",
|
|
36
|
+
"webpack-remove-empty-scripts": "^1.0.4"
|
|
37
|
+
},
|
|
38
|
+
"eslintConfig": {
|
|
39
|
+
"extends": [
|
|
40
|
+
"plugin:@wordpress/eslint-plugin/recommended"
|
|
41
|
+
],
|
|
42
|
+
"rules": {
|
|
43
|
+
"import/no-extraneous-dependencies": 0
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"prettier": "@wordpress/prettier-config"
|
|
47
|
+
}
|
package/wp/phpcs.xml
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<?xml version="1.0"?>
|
|
2
|
+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="theme"
|
|
3
|
+
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
|
|
4
|
+
|
|
5
|
+
<description>A custom set of rules to check for a WordPress project</description>
|
|
6
|
+
|
|
7
|
+
<exclude-pattern>/vendor/*</exclude-pattern>
|
|
8
|
+
<exclude-pattern>/node_modules/*</exclude-pattern>
|
|
9
|
+
<exclude-pattern>/dist/*</exclude-pattern>
|
|
10
|
+
|
|
11
|
+
<arg name="extensions" value="php" />
|
|
12
|
+
|
|
13
|
+
<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties -->
|
|
14
|
+
|
|
15
|
+
<rule ref="WordPress-Extra">
|
|
16
|
+
<!-- I want to drop this exception after version 3 is released. -->
|
|
17
|
+
<exclude name="PSR12.Functions.ReturnTypeDeclaration" />
|
|
18
|
+
<!-- This needs to be discussed, since this is indeed not used correctly, including in our topic. -->
|
|
19
|
+
<exclude name="Universal.Operators.DisallowShortTernary" />
|
|
20
|
+
</rule>
|
|
21
|
+
|
|
22
|
+
<rule ref="WordPress.WP.I18n">
|
|
23
|
+
<properties>
|
|
24
|
+
<property name="text_domain" type="array">
|
|
25
|
+
<element value="theme" />
|
|
26
|
+
<element value="woocommerce" />
|
|
27
|
+
<element value="default" />
|
|
28
|
+
</property>
|
|
29
|
+
</properties>
|
|
30
|
+
</rule>
|
|
31
|
+
|
|
32
|
+
<rule ref="Universal.WhiteSpace.PrecisionAlignment">
|
|
33
|
+
<properties>
|
|
34
|
+
<property name="ignoreAlignmentBefore" type="array">
|
|
35
|
+
<element value="T_INLINE_HTML" />
|
|
36
|
+
</property>
|
|
37
|
+
</properties>
|
|
38
|
+
</rule>
|
|
39
|
+
|
|
40
|
+
<rule ref="WordPress.Security.EscapeOutput">
|
|
41
|
+
<properties>
|
|
42
|
+
<property name="customAutoEscapedFunctions" type="array">
|
|
43
|
+
<element value="wld_get" />
|
|
44
|
+
<element value="wld_get_as" />
|
|
45
|
+
<element value="wld_get_value" />
|
|
46
|
+
<element value="wld_get_attrs" />
|
|
47
|
+
<element value="wld_get_template_part" />
|
|
48
|
+
</property>
|
|
49
|
+
</properties>
|
|
50
|
+
</rule>
|
|
51
|
+
|
|
52
|
+
<rule ref="WordPress.WP.Capabilities">
|
|
53
|
+
<properties>
|
|
54
|
+
<property name="custom_capabilities" type="array">
|
|
55
|
+
<element value="manage_woocommerce" />
|
|
56
|
+
</property>
|
|
57
|
+
</properties>
|
|
58
|
+
</rule>
|
|
59
|
+
|
|
60
|
+
</ruleset>
|
package/wp/tsconfig.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @see https://github.com/WordPress/gutenberg/blob/trunk/tsconfig.base.json
|
|
3
|
+
*/
|
|
4
|
+
{
|
|
5
|
+
"$schema": "https://json.schemastore.org/tsconfig.json",
|
|
6
|
+
"compilerOptions": {
|
|
7
|
+
"allowJs": false,
|
|
8
|
+
"checkJs": false,
|
|
9
|
+
"allowSyntheticDefaultImports": true,
|
|
10
|
+
"jsx": "preserve",
|
|
11
|
+
"target": "esnext",
|
|
12
|
+
"module": "esnext",
|
|
13
|
+
"lib": [ "DOM", "DOM.Iterable", "ESNext" ],
|
|
14
|
+
"declaration": true,
|
|
15
|
+
"declarationMap": true,
|
|
16
|
+
"composite": true,
|
|
17
|
+
"emitDeclarationOnly": true,
|
|
18
|
+
"isolatedModules": true,
|
|
19
|
+
|
|
20
|
+
/* Strict Type-Checking Options */
|
|
21
|
+
"strict": true,
|
|
22
|
+
|
|
23
|
+
/* Additional Checks */
|
|
24
|
+
"noUnusedLocals": true,
|
|
25
|
+
"noUnusedParameters": true,
|
|
26
|
+
"noImplicitReturns": true,
|
|
27
|
+
"noFallthroughCasesInSwitch": true,
|
|
28
|
+
|
|
29
|
+
/* Module Resolution Options */
|
|
30
|
+
"moduleResolution": "node",
|
|
31
|
+
|
|
32
|
+
/* This needs to be false so our types are possible to consume without setting this */
|
|
33
|
+
"esModuleInterop": false,
|
|
34
|
+
"resolveJsonModule": true,
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const MiniCSSExtractPlugin = require( 'mini-css-extract-plugin' );
|
|
2
|
+
const RtlCssPlugin = require( 'rtlcss-webpack-plugin' );
|
|
3
|
+
const { CleanWebpackPlugin } = require( 'clean-webpack-plugin' );
|
|
4
|
+
const {
|
|
5
|
+
Config,
|
|
6
|
+
defaultConfigWP,
|
|
7
|
+
modulesConfigWP,
|
|
8
|
+
} = require( '../helpers/webpack' );
|
|
9
|
+
|
|
10
|
+
const defaultConfig = new Config(
|
|
11
|
+
defaultConfigWP,
|
|
12
|
+
'default',
|
|
13
|
+
process.env.THEME_BLOCK_DEV_SERVER_PORT || 'auto'
|
|
14
|
+
)
|
|
15
|
+
.addEntries( 'src/**/styles/*.{pc,sc,sa,c}ss' )
|
|
16
|
+
.removePlugin( RtlCssPlugin )
|
|
17
|
+
.replacePlugin(
|
|
18
|
+
new MiniCSSExtractPlugin( {
|
|
19
|
+
filename( pathData ) {
|
|
20
|
+
return `${ pathData.chunk.name.replace(
|
|
21
|
+
'/scripts/',
|
|
22
|
+
'/styles/'
|
|
23
|
+
) }.css`;
|
|
24
|
+
},
|
|
25
|
+
} )
|
|
26
|
+
)
|
|
27
|
+
.addPlugin(
|
|
28
|
+
new CleanWebpackPlugin( {
|
|
29
|
+
cleanOnceBeforeBuildPatterns: [ '!**/*module*,' ],
|
|
30
|
+
cleanStaleWebpackAssets: false,
|
|
31
|
+
} ),
|
|
32
|
+
'before'
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const modulesConfig = new Config( modulesConfigWP, 'modules' );
|
|
36
|
+
|
|
37
|
+
module.exports = [ defaultConfig.get(), modulesConfig.get() ];
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
const { CleanWebpackPlugin } = require( 'clean-webpack-plugin' );
|
|
2
|
+
const CopyWebpackPlugin = require( 'copy-webpack-plugin' );
|
|
3
|
+
const RemoveEmptyScriptsPlugin = require( 'webpack-remove-empty-scripts' );
|
|
4
|
+
const RtlCssPlugin = require( 'rtlcss-webpack-plugin' );
|
|
5
|
+
const ImageMinimizerPlugin = require( 'image-minimizer-webpack-plugin' );
|
|
6
|
+
const { resolve } = require( 'node:path' );
|
|
7
|
+
const {
|
|
8
|
+
Config,
|
|
9
|
+
defaultConfigWP,
|
|
10
|
+
modulesConfigWP,
|
|
11
|
+
} = require( '../helpers/webpack' );
|
|
12
|
+
|
|
13
|
+
const defaultConfig = new Config(
|
|
14
|
+
defaultConfigWP,
|
|
15
|
+
'default',
|
|
16
|
+
process.env.THEME_DEV_SERVER_PORT || 'auto'
|
|
17
|
+
)
|
|
18
|
+
.resetEntries()
|
|
19
|
+
.addEntries(
|
|
20
|
+
'src/styles/{*.{pc,sc,sa,c}ss,{blocks,variations,patterns}/**/*.{pc,sc,sa,c}ss}'
|
|
21
|
+
)
|
|
22
|
+
.addEntries( 'src/scripts/*.{j,t}s' )
|
|
23
|
+
.changeRule( '/\\.(sc|sa)ss$/', ( rule ) => {
|
|
24
|
+
const last = rule.use.length - 1;
|
|
25
|
+
const root = process.cwd();
|
|
26
|
+
|
|
27
|
+
rule.use[ last ].options.sassOptions = {
|
|
28
|
+
includePaths: [ resolve( root, 'src/styles/partials' ) ],
|
|
29
|
+
};
|
|
30
|
+
} )
|
|
31
|
+
.removePlugin( RtlCssPlugin )
|
|
32
|
+
.addPlugin(
|
|
33
|
+
new CleanWebpackPlugin( {
|
|
34
|
+
cleanOnceBeforeBuildPatterns: [ '!modules/**' ],
|
|
35
|
+
cleanStaleWebpackAssets: false,
|
|
36
|
+
} ),
|
|
37
|
+
'before'
|
|
38
|
+
)
|
|
39
|
+
.addPlugin(
|
|
40
|
+
// For styles remove JS and styles .asset.php
|
|
41
|
+
new RemoveEmptyScriptsPlugin( {
|
|
42
|
+
enabled: ! Config.hasDevServer( defaultConfigWP ),
|
|
43
|
+
} )
|
|
44
|
+
)
|
|
45
|
+
.addPlugin(
|
|
46
|
+
new CopyWebpackPlugin( {
|
|
47
|
+
patterns: [
|
|
48
|
+
{
|
|
49
|
+
from: 'src/fonts',
|
|
50
|
+
to: 'fonts',
|
|
51
|
+
noErrorOnMissing: true,
|
|
52
|
+
globOptions: {
|
|
53
|
+
ignore: [ '**/readme.md' ],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
from: 'src/social-icons',
|
|
58
|
+
to: 'social-icons',
|
|
59
|
+
noErrorOnMissing: true,
|
|
60
|
+
globOptions: {
|
|
61
|
+
ignore: [ '**/readme.md' ],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
from: 'src/menu-icons',
|
|
66
|
+
to: 'menu-icons',
|
|
67
|
+
noErrorOnMissing: true,
|
|
68
|
+
globOptions: {
|
|
69
|
+
ignore: [ '**/readme.md' ],
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
} )
|
|
74
|
+
)
|
|
75
|
+
.addMinimizer(
|
|
76
|
+
new ImageMinimizerPlugin( {
|
|
77
|
+
minimizer: {
|
|
78
|
+
implementation: ImageMinimizerPlugin.svgoMinify,
|
|
79
|
+
options: {
|
|
80
|
+
encodeOptions: {
|
|
81
|
+
multipass: true,
|
|
82
|
+
plugins: [
|
|
83
|
+
{
|
|
84
|
+
name: 'preset-default',
|
|
85
|
+
params: {
|
|
86
|
+
overrides: {
|
|
87
|
+
removeViewBox: false,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'addAttributesToSVGElement',
|
|
93
|
+
params: {
|
|
94
|
+
attributes: [
|
|
95
|
+
{
|
|
96
|
+
'aria-hidden': 'true',
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
} )
|
|
106
|
+
)
|
|
107
|
+
.addMinimizer(
|
|
108
|
+
new ImageMinimizerPlugin( {
|
|
109
|
+
minimizer: {
|
|
110
|
+
implementation: ImageMinimizerPlugin.sharpMinify,
|
|
111
|
+
},
|
|
112
|
+
generator: [
|
|
113
|
+
{
|
|
114
|
+
type: 'asset',
|
|
115
|
+
preset: 'avif',
|
|
116
|
+
implementation: ImageMinimizerPlugin.sharpGenerate,
|
|
117
|
+
options: {
|
|
118
|
+
encodeOptions: {
|
|
119
|
+
avif: {
|
|
120
|
+
lossless: false,
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
} )
|
|
127
|
+
)
|
|
128
|
+
.addWatch( 'src/scripts/modules/*' );
|
|
129
|
+
|
|
130
|
+
const modulesConfig = new Config( modulesConfigWP, 'modules' )
|
|
131
|
+
.resetEntries()
|
|
132
|
+
.addEntries( 'src/scripts/modules/*.{j,t}s' );
|
|
133
|
+
|
|
134
|
+
const patternsConfig = new Config( { entry: {} }, 'patterns' )
|
|
135
|
+
.addPlugin(
|
|
136
|
+
new CopyWebpackPlugin( {
|
|
137
|
+
patterns: [
|
|
138
|
+
{
|
|
139
|
+
from: 'src/images-for-patterns',
|
|
140
|
+
to: '../patterns/images',
|
|
141
|
+
noErrorOnMissing: true,
|
|
142
|
+
globOptions: {
|
|
143
|
+
ignore: [ '**/readme.md' ],
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
} )
|
|
148
|
+
)
|
|
149
|
+
.addMinimizer(
|
|
150
|
+
new ImageMinimizerPlugin( {
|
|
151
|
+
minimizer: {
|
|
152
|
+
implementation: ImageMinimizerPlugin.svgoMinify,
|
|
153
|
+
options: {
|
|
154
|
+
encodeOptions: {
|
|
155
|
+
multipass: true,
|
|
156
|
+
plugins: [
|
|
157
|
+
{
|
|
158
|
+
name: 'preset-default',
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: 'addAttributesToSVGElement',
|
|
162
|
+
params: {
|
|
163
|
+
attributes: [
|
|
164
|
+
{
|
|
165
|
+
'aria-hidden': 'true',
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
} )
|
|
175
|
+
)
|
|
176
|
+
.addMinimizer(
|
|
177
|
+
new ImageMinimizerPlugin( {
|
|
178
|
+
minimizer: {
|
|
179
|
+
implementation: ImageMinimizerPlugin.sharpMinify,
|
|
180
|
+
},
|
|
181
|
+
generator: [
|
|
182
|
+
{
|
|
183
|
+
type: 'asset',
|
|
184
|
+
preset: 'avif',
|
|
185
|
+
implementation: ImageMinimizerPlugin.sharpGenerate,
|
|
186
|
+
options: {
|
|
187
|
+
encodeOptions: {
|
|
188
|
+
avif: {
|
|
189
|
+
lossless: false,
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
} )
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
module.exports = [
|
|
199
|
+
defaultConfig.get(),
|
|
200
|
+
modulesConfig.get(),
|
|
201
|
+
patternsConfig.get(),
|
|
202
|
+
];
|