README
gulp-links-state-replacer
Adds and removes suffixes (example: .min) in the path to mount files depending on the variable passed or the values passed to --env (dev or prod)
! ! !
The package is still under development!
It doesn't work.
You can save to bookmarks!
! ! !
Default options
let options = {
env: 'dev',
files: [],
exceptions: {},
patterns: {
link: '<link*href=#%#*>',
script: '<script*src=#%#*></script>'
},
rules: {
suff: {
link: {
'dev': '',
'prod': 'min'
},
script: {
'dev': '',
'prod': 'min'
}
}
}
}
Explanation of options
env
(default:'dev'
) -- pass astring
with the name of your development mode.files
(default:[]
) -- send aarray
of files to be processed.
{
files: [
'/path/index.html'
]
}
exceptions
(default:{}
) -- exceptions means ignoring in the path file (link, src or other pattern), pass theobject
.
{
exceptions: {
'index.html': {
link: [
'assets/css/style.min.css'
],
script: [
'assets/js/main.min.js'
],
custom: [
'assets/test.custom'
]
}
}
}
You can see the following:
- Ignoring will be done in the index .html file.
- In link, script and custom patterns.
- Only in patterns that contain the following paths with file names:
style.min.css
,main.min.js
,test.custom
.
Read more about patterns.
patterns
(default:object
) -- here are the tags between which you want to look for the path attribute.
To use a pattern in settings, you must create one!
{
patterns: {
link: '<link*href=#%#*>',
script: '<script*src=#%#*></script>'
}
}
Symbols of patterns
To use the following characters as plain text add an inverted slash.
Using the following characters in the path will break the program!
* - zero or more characters to skip to the next symbol.
% - the file path specified in the attribute.
# - a symbol that includes single or double quotes.
To use only single or binary quotation marks, use their symbol instead of the grid.
Let's cut out one of the patterns and see what's in it.
<script - simple text
* - any number of characters to the next plain text
src= - simple text
# - single or double quotes
% - file path
# - single or double quotes
* - any number of characters to the next plain text
></script> - simple text
You can use other types of patterns, but the package was tested only on html and custom tags.
rules
(default:object
) -- if the files match the pattern, the suffix is added or removed depending on the mode.suff
(deafult:object
) -- depending on the mode, the suffix is added or removed.
{
rules: {
suff: {
'*': {
'dev': '',
'prod': 'min'
},
}
}
}
The sign *
means - all patterns. You can specify separately for each pattern.
To write a rule for a pattern, you need to create it! Read about creating a pattern above.
suffix rules
for a file
Overwrite To overwrite rules for a file, you must specify an array instead of a string.
{
files: {
['path/overwrited.html', {
suff: {
link: {
'dev': 'min',
'prod': ''
}
}
}]
}
}
What we did:
- Rewrote the rules for the
link
. Now whenenv
is equal todev
the suffixmin
will be added, and whenmin
, it will be removed.
To overwrite all suffix patterns, use *
.
{
files: {
['path/overwrited.html', {
suff: {
'*': {
'dev': 'min',
'prod': ''
}
}
}]
}
}
How to run it?
soon...
How to work with gulp?
soon...
How to manage extensions?
soon...
How to debug it?
soon...