weboptimizer 2.0.1562 → 2.0.1563
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/package.json +3 -3
- package/webpackConfigurator.js +87 -38
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weboptimizer",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1563",
|
|
4
4
|
"description": "A generic web optimizer, (module) bundler and development environment.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
"mini-css-extract-plugin": "^2.9.2",
|
|
149
149
|
"mkdirp": "^3.0.1",
|
|
150
150
|
"node-fetch": "^3.3.2",
|
|
151
|
-
"postcss": "^8.5.
|
|
151
|
+
"postcss": "^8.5.3",
|
|
152
152
|
"postcss-fontpath": "^1.0.0",
|
|
153
153
|
"postcss-import": "^16.1.0",
|
|
154
154
|
"postcss-loader": "^8.1.1",
|
|
@@ -1099,7 +1099,7 @@
|
|
|
1099
1099
|
},
|
|
1100
1100
|
"compress": {
|
|
1101
1101
|
"html": {
|
|
1102
|
-
"__evaluate__": "self.module.optimizer.htmlMinifier"
|
|
1102
|
+
"__evaluate__": "type && type.includes('html') && self.module.optimizer.htmlMinifier"
|
|
1103
1103
|
},
|
|
1104
1104
|
"javaScript": {
|
|
1105
1105
|
"__evaluate__": "self.module.optimizer.babelMinify.module"
|
package/webpackConfigurator.js
CHANGED
|
@@ -593,23 +593,34 @@ var scope = {
|
|
|
593
593
|
require: currentRequire !== null && currentRequire !== void 0 ? currentRequire : require
|
|
594
594
|
};
|
|
595
595
|
var evaluateAnThrow = function evaluateAnThrow(object) {
|
|
596
|
-
var
|
|
596
|
+
var givenOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
597
|
+
var options = _objectSpread({
|
|
598
|
+
filePath: configuration.path.context
|
|
599
|
+
}, givenOptions);
|
|
597
600
|
if (typeof object === 'string') {
|
|
598
|
-
var evaluated = (0, _clientnode.evaluate)(object, _objectSpread({
|
|
599
|
-
filePath: filePath
|
|
600
|
-
}, scope)
|
|
601
|
+
var evaluated = (0, _clientnode.evaluate)(object, _objectSpread(_objectSpread({
|
|
602
|
+
filePath: options.filePath
|
|
603
|
+
}, scope), {}, {
|
|
604
|
+
type: options.type
|
|
605
|
+
}));
|
|
601
606
|
if (evaluated.error) throw new Error('Error occurred during processing given expression: ' + evaluated.error);
|
|
602
607
|
return evaluated.result;
|
|
603
608
|
}
|
|
604
609
|
return object;
|
|
605
610
|
};
|
|
606
|
-
var
|
|
607
|
-
return
|
|
611
|
+
var createEvaluateMapper = function createEvaluateMapper(type) {
|
|
612
|
+
return function (value) {
|
|
613
|
+
return evaluateAnThrow(value, {
|
|
614
|
+
type: type
|
|
615
|
+
});
|
|
616
|
+
};
|
|
608
617
|
};
|
|
609
618
|
var evaluateAdditionalLoaderConfiguration = function evaluateAdditionalLoaderConfiguration(loaderConfiguration) {
|
|
610
619
|
return {
|
|
611
620
|
exclude: function exclude(filePath) {
|
|
612
|
-
return evaluateAnThrow(loaderConfiguration.exclude,
|
|
621
|
+
return evaluateAnThrow(loaderConfiguration.exclude, {
|
|
622
|
+
filePath: filePath
|
|
623
|
+
});
|
|
613
624
|
},
|
|
614
625
|
include: loaderConfiguration.include && evaluateAnThrow(loaderConfiguration.include) || configuration.path.source.base,
|
|
615
626
|
test: new RegExp(evaluateAnThrow(loaderConfiguration.test)),
|
|
@@ -619,7 +630,7 @@ var evaluateAdditionalLoaderConfiguration = function evaluateAdditionalLoaderCon
|
|
|
619
630
|
var getIncludingPaths = function getIncludingPaths(path) {
|
|
620
631
|
return (0, _helper.normalizePaths)([path].concat(_module.locations.directoryPaths));
|
|
621
632
|
};
|
|
622
|
-
var cssUse = _module.preprocessor.cascadingStyleSheet.additional.pre.map(
|
|
633
|
+
var cssUse = _module.preprocessor.cascadingStyleSheet.additional.pre.map(createEvaluateMapper('css')).concat({
|
|
623
634
|
loader: _module.style.loader,
|
|
624
635
|
options: _module.style.options || {}
|
|
625
636
|
}, {
|
|
@@ -636,7 +647,7 @@ var cssUse = _module.preprocessor.cascadingStyleSheet.additional.pre.map(evaluat
|
|
|
636
647
|
*/
|
|
637
648
|
plugins: [].concat(postcssImport ? postcssImport({
|
|
638
649
|
root: configuration.path.context
|
|
639
|
-
}) : [], _module.preprocessor.cascadingStyleSheet.additional.plugins.pre.map(
|
|
650
|
+
}) : [], _module.preprocessor.cascadingStyleSheet.additional.plugins.pre.map(createEvaluateMapper('css.postcss')),
|
|
640
651
|
/*
|
|
641
652
|
NOTE: Checking path doesn't work if fonts
|
|
642
653
|
are referenced in libraries provided in
|
|
@@ -681,10 +692,10 @@ var cssUse = _module.preprocessor.cascadingStyleSheet.additional.pre.map(evaluat
|
|
|
681
692
|
},
|
|
682
693
|
stylesheetPath: configuration.path.source.asset.cascadingStyleSheet,
|
|
683
694
|
spritePath: configuration.path.source.asset.image
|
|
684
|
-
}) : [], _module.preprocessor.cascadingStyleSheet.additional.plugins.post.map(
|
|
695
|
+
}) : [], _module.preprocessor.cascadingStyleSheet.additional.plugins.post.map(createEvaluateMapper('css.postcss')), _module.optimizer.cssnano && postcssCSSnano ? postcssCSSnano(_module.optimizer.cssnano) : [])
|
|
685
696
|
}
|
|
686
697
|
} : {}, _module.preprocessor.cascadingStyleSheet.options || {})
|
|
687
|
-
} : [], _module.preprocessor.cascadingStyleSheet.additional.post.map(
|
|
698
|
+
} : [], _module.preprocessor.cascadingStyleSheet.additional.post.map(createEvaluateMapper('css')));
|
|
688
699
|
var genericLoader = {
|
|
689
700
|
// Convert to compatible native web types.
|
|
690
701
|
// region generic template
|
|
@@ -692,23 +703,31 @@ var genericLoader = {
|
|
|
692
703
|
exclude: function exclude(filePath) {
|
|
693
704
|
return (0, _helper.normalizePaths)(configuration.files.html.concat(configuration.files.defaultHTML).map(function (htmlConfiguration) {
|
|
694
705
|
return htmlConfiguration.template.filePath;
|
|
695
|
-
})).includes(filePath) || _module.preprocessor.ejs.exclude === null ? false : evaluateAnThrow(_module.preprocessor.ejs.exclude,
|
|
706
|
+
})).includes(filePath) || _module.preprocessor.ejs.exclude === null ? false : evaluateAnThrow(_module.preprocessor.ejs.exclude, {
|
|
707
|
+
filePath: filePath
|
|
708
|
+
});
|
|
696
709
|
},
|
|
697
710
|
include: getIncludingPaths(configuration.path.source.asset.template),
|
|
698
711
|
test: /^(?!.+\.html\.ejs$).+\.ejs$/i,
|
|
699
|
-
use: _module.preprocessor.ejs.additional.pre.map(
|
|
712
|
+
use: _module.preprocessor.ejs.additional.pre.map(createEvaluateMapper('ejs')).concat({
|
|
700
713
|
loader: _module.preprocessor.ejs.loader,
|
|
701
714
|
options: _module.preprocessor.ejs.options || {}
|
|
702
|
-
}, _module.preprocessor.ejs.additional.post.map(
|
|
715
|
+
}, _module.preprocessor.ejs.additional.post.map(createEvaluateMapper('ejs')))
|
|
703
716
|
},
|
|
704
717
|
// endregion
|
|
705
718
|
// region script
|
|
706
719
|
script: {
|
|
707
720
|
exclude: function exclude(filePath) {
|
|
708
|
-
return evaluateAnThrow(_module.preprocessor.javaScript.exclude,
|
|
721
|
+
return evaluateAnThrow(_module.preprocessor.javaScript.exclude, {
|
|
722
|
+
filePath: filePath,
|
|
723
|
+
type: 'script'
|
|
724
|
+
});
|
|
709
725
|
},
|
|
710
726
|
include: function include(filePath) {
|
|
711
|
-
var result = evaluateAnThrow(_module.preprocessor.javaScript.include,
|
|
727
|
+
var result = evaluateAnThrow(_module.preprocessor.javaScript.include, {
|
|
728
|
+
filePath: filePath,
|
|
729
|
+
type: 'script'
|
|
730
|
+
});
|
|
712
731
|
if ([null, undefined].includes(result)) {
|
|
713
732
|
var _iterator10 = _createForOfIteratorHelper(getIncludingPaths(configuration.path.source.asset.javaScript)),
|
|
714
733
|
_step10;
|
|
@@ -727,10 +746,10 @@ var genericLoader = {
|
|
|
727
746
|
return Boolean(result);
|
|
728
747
|
},
|
|
729
748
|
test: new RegExp(_module.preprocessor.javaScript.regularExpression, 'i'),
|
|
730
|
-
use: _module.preprocessor.javaScript.additional.pre.map(
|
|
749
|
+
use: _module.preprocessor.javaScript.additional.pre.map(createEvaluateMapper('script')).concat({
|
|
731
750
|
loader: _module.preprocessor.javaScript.loader,
|
|
732
751
|
options: _module.preprocessor.javaScript.options || {}
|
|
733
|
-
}, _module.preprocessor.javaScript.additional.post.map(
|
|
752
|
+
}, _module.preprocessor.javaScript.additional.post.map(createEvaluateMapper('script')))
|
|
734
753
|
},
|
|
735
754
|
// endregion
|
|
736
755
|
// region html template
|
|
@@ -744,11 +763,14 @@ var genericLoader = {
|
|
|
744
763
|
exclude: function exclude(filePath) {
|
|
745
764
|
return (0, _helper.normalizePaths)(configuration.files.html.concat(configuration.files.defaultHTML).map(function (htmlConfiguration) {
|
|
746
765
|
return htmlConfiguration.template.filePath;
|
|
747
|
-
})).includes(filePath) || (_module.preprocessor.html.exclude === null ? false : evaluateAnThrow(_module.preprocessor.html.exclude,
|
|
766
|
+
})).includes(filePath) || (_module.preprocessor.html.exclude === null ? false : evaluateAnThrow(_module.preprocessor.html.exclude, {
|
|
767
|
+
filePath: filePath,
|
|
768
|
+
type: 'html.ejs'
|
|
769
|
+
}));
|
|
748
770
|
},
|
|
749
771
|
include: configuration.path.source.asset.template,
|
|
750
772
|
test: /\.html\.ejs(?: \?.*)?$/i,
|
|
751
|
-
use: _module.preprocessor.html.additional.pre.map(
|
|
773
|
+
use: _module.preprocessor.html.additional.pre.map(createEvaluateMapper('html.ejs')).concat(
|
|
752
774
|
/*
|
|
753
775
|
We might need to evaluate ejs before we are able to
|
|
754
776
|
parse html beforhand. If not we parse it as html
|
|
@@ -765,24 +787,27 @@ var genericLoader = {
|
|
|
765
787
|
}], {
|
|
766
788
|
loader: _module.preprocessor.html.loader,
|
|
767
789
|
options: _module.preprocessor.html.options || {}
|
|
768
|
-
}, _module.preprocessor.html.additional.post.map(
|
|
790
|
+
}, _module.preprocessor.html.additional.post.map(createEvaluateMapper('html.ejs')))
|
|
769
791
|
},
|
|
770
792
|
html: {
|
|
771
793
|
exclude: function exclude(filePath) {
|
|
772
794
|
return (0, _helper.normalizePaths)(configuration.files.html.concat(configuration.files.defaultHTML).map(function (htmlConfiguration) {
|
|
773
795
|
return htmlConfiguration.template.filePath;
|
|
774
|
-
})).includes(filePath) || (_module.html.exclude === null ? true : evaluateAnThrow(_module.html.exclude,
|
|
796
|
+
})).includes(filePath) || (_module.html.exclude === null ? true : evaluateAnThrow(_module.html.exclude, {
|
|
797
|
+
filePath: filePath,
|
|
798
|
+
type: 'html'
|
|
799
|
+
}));
|
|
775
800
|
},
|
|
776
801
|
include: configuration.path.source.asset.template,
|
|
777
802
|
test: /\.html(?: \?.*)?$/i,
|
|
778
|
-
use: _module.html.additional.pre.map(
|
|
803
|
+
use: _module.html.additional.pre.map(createEvaluateMapper('html')).concat({
|
|
779
804
|
loader: 'file?name=' + (0, _path.join)((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset.template), "[name][ext]?".concat(configuration.hashAlgorithm, "=") + '[contenthash]')
|
|
780
805
|
}, {
|
|
781
806
|
loader: 'extract'
|
|
782
807
|
}, {
|
|
783
808
|
loader: _module.html.loader,
|
|
784
809
|
options: _module.html.options || {}
|
|
785
|
-
}, _module.html.additional.post.map(
|
|
810
|
+
}, _module.html.additional.post.map(createEvaluateMapper('html')))
|
|
786
811
|
}
|
|
787
812
|
},
|
|
788
813
|
// endregion
|
|
@@ -790,10 +815,16 @@ var genericLoader = {
|
|
|
790
815
|
// region style
|
|
791
816
|
style: {
|
|
792
817
|
exclude: function exclude(filePath) {
|
|
793
|
-
return _module.cascadingStyleSheet.exclude === null ? isFilePathInDependencies(filePath) : evaluateAnThrow(_module.cascadingStyleSheet.exclude,
|
|
818
|
+
return _module.cascadingStyleSheet.exclude === null ? isFilePathInDependencies(filePath) : evaluateAnThrow(_module.cascadingStyleSheet.exclude, {
|
|
819
|
+
filePath: filePath,
|
|
820
|
+
type: 'style'
|
|
821
|
+
});
|
|
794
822
|
},
|
|
795
823
|
include: function include(filePath) {
|
|
796
|
-
var result = evaluateAnThrow(_module.cascadingStyleSheet.include,
|
|
824
|
+
var result = evaluateAnThrow(_module.cascadingStyleSheet.include, {
|
|
825
|
+
filePath: filePath,
|
|
826
|
+
type: 'style'
|
|
827
|
+
});
|
|
797
828
|
if ([null, undefined].includes(result)) {
|
|
798
829
|
var _iterator11 = _createForOfIteratorHelper(getIncludingPaths(configuration.path.source.asset.cascadingStyleSheet)),
|
|
799
830
|
_step11;
|
|
@@ -820,7 +851,10 @@ var genericLoader = {
|
|
|
820
851
|
font: {
|
|
821
852
|
eot: {
|
|
822
853
|
exclude: function exclude(filePath) {
|
|
823
|
-
return _module.optimizer.font.eot.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.eot.exclude,
|
|
854
|
+
return _module.optimizer.font.eot.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.eot.exclude, {
|
|
855
|
+
filePath: filePath,
|
|
856
|
+
type: 'font.eot'
|
|
857
|
+
});
|
|
824
858
|
},
|
|
825
859
|
generator: {
|
|
826
860
|
filename: (0, _path.join)((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset.font), '[name][ext]') + "?".concat(configuration.hashAlgorithm, "=[contenthash]")
|
|
@@ -832,11 +866,14 @@ var genericLoader = {
|
|
|
832
866
|
maxSize: configuration.inPlace.otherMaximumFileSizeLimitInByte
|
|
833
867
|
}
|
|
834
868
|
},
|
|
835
|
-
use: _module.optimizer.font.eot.loader.map(
|
|
869
|
+
use: _module.optimizer.font.eot.loader.map(createEvaluateMapper('font.eot'))
|
|
836
870
|
},
|
|
837
871
|
svg: {
|
|
838
872
|
exclude: function exclude(filePath) {
|
|
839
|
-
return _module.optimizer.font.svg.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.svg.exclude,
|
|
873
|
+
return _module.optimizer.font.svg.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.svg.exclude, {
|
|
874
|
+
filePath: filePath,
|
|
875
|
+
type: 'svg'
|
|
876
|
+
});
|
|
840
877
|
},
|
|
841
878
|
include: configuration.path.source.asset.font,
|
|
842
879
|
generator: {
|
|
@@ -850,11 +887,14 @@ var genericLoader = {
|
|
|
850
887
|
},
|
|
851
888
|
test: /\.svg(?: \?.*)?$/i,
|
|
852
889
|
type: 'asset/resource',
|
|
853
|
-
use: _module.optimizer.font.svg.loader.map(
|
|
890
|
+
use: _module.optimizer.font.svg.loader.map(createEvaluateMapper('font.svg'))
|
|
854
891
|
},
|
|
855
892
|
ttf: {
|
|
856
893
|
exclude: function exclude(filePath) {
|
|
857
|
-
return _module.optimizer.font.ttf.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.ttf.exclude,
|
|
894
|
+
return _module.optimizer.font.ttf.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.ttf.exclude, {
|
|
895
|
+
filePath: filePath,
|
|
896
|
+
type: 'ttf'
|
|
897
|
+
});
|
|
858
898
|
},
|
|
859
899
|
generator: {
|
|
860
900
|
filename: (0, _path.join)((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset.font), '[name][ext]') + "?".concat(configuration.hashAlgorithm, "=[contenthash]")
|
|
@@ -867,11 +907,14 @@ var genericLoader = {
|
|
|
867
907
|
maxSize: configuration.inPlace.otherMaximumFileSizeLimitInByte
|
|
868
908
|
}
|
|
869
909
|
},
|
|
870
|
-
use: _module.optimizer.font.ttf.loader.map(
|
|
910
|
+
use: _module.optimizer.font.ttf.loader.map(createEvaluateMapper('font.ttf'))
|
|
871
911
|
},
|
|
872
912
|
woff: {
|
|
873
913
|
exclude: function exclude(filePath) {
|
|
874
|
-
return _module.optimizer.font.woff.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.woff.exclude,
|
|
914
|
+
return _module.optimizer.font.woff.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.woff.exclude, {
|
|
915
|
+
filePath: filePath,
|
|
916
|
+
type: 'woff'
|
|
917
|
+
});
|
|
875
918
|
},
|
|
876
919
|
generator: {
|
|
877
920
|
filename: (0, _path.join)((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset.font), '[name][ext]') + "?".concat(configuration.hashAlgorithm, "=[contenthash]")
|
|
@@ -883,14 +926,17 @@ var genericLoader = {
|
|
|
883
926
|
maxSize: configuration.inPlace.otherMaximumFileSizeLimitInByte
|
|
884
927
|
}
|
|
885
928
|
},
|
|
886
|
-
use: _module.optimizer.font.woff.loader.map(
|
|
929
|
+
use: _module.optimizer.font.woff.loader.map(createEvaluateMapper('font.woff'))
|
|
887
930
|
}
|
|
888
931
|
},
|
|
889
932
|
// endregion
|
|
890
933
|
// region image
|
|
891
934
|
image: {
|
|
892
935
|
exclude: function exclude(filePath) {
|
|
893
|
-
return _module.optimizer.image.exclude === null ? isFilePathInDependencies(filePath) : evaluateAnThrow(_module.optimizer.image.exclude,
|
|
936
|
+
return _module.optimizer.image.exclude === null ? isFilePathInDependencies(filePath) : evaluateAnThrow(_module.optimizer.image.exclude, {
|
|
937
|
+
filePath: filePath,
|
|
938
|
+
type: 'image'
|
|
939
|
+
});
|
|
894
940
|
},
|
|
895
941
|
generator: {
|
|
896
942
|
filename: (0, _path.join)((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset.image), '[name][ext]') + "?".concat(configuration.hashAlgorithm, "=[contenthash]")
|
|
@@ -903,14 +949,17 @@ var genericLoader = {
|
|
|
903
949
|
maxSize: configuration.inPlace.otherMaximumFileSizeLimitInByte
|
|
904
950
|
}
|
|
905
951
|
},
|
|
906
|
-
use: _module.optimizer.image.loader.map(
|
|
952
|
+
use: _module.optimizer.image.loader.map(createEvaluateMapper('image'))
|
|
907
953
|
},
|
|
908
954
|
// endregion
|
|
909
955
|
// region data
|
|
910
956
|
data: {
|
|
911
957
|
exclude: function exclude(filePath) {
|
|
912
958
|
if (typeof filePath !== 'string') return false;
|
|
913
|
-
return configuration.extensions.file.internal.includes((0, _path.extname)((0, _helper.stripLoader)(filePath))) || (_module.optimizer.data.exclude === null ? isFilePathInDependencies(filePath) : evaluateAnThrow(_module.optimizer.data.exclude,
|
|
959
|
+
return configuration.extensions.file.internal.includes((0, _path.extname)((0, _helper.stripLoader)(filePath))) || (_module.optimizer.data.exclude === null ? isFilePathInDependencies(filePath) : evaluateAnThrow(_module.optimizer.data.exclude, {
|
|
960
|
+
filePath: filePath,
|
|
961
|
+
type: 'data'
|
|
962
|
+
}));
|
|
914
963
|
},
|
|
915
964
|
generator: {
|
|
916
965
|
filename: (0, _path.join)((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset.data), '[name][ext]') + "?".concat(configuration.hashAlgorithm, "=[contenthash]")
|
|
@@ -922,7 +971,7 @@ var genericLoader = {
|
|
|
922
971
|
maxSize: configuration.inPlace.otherMaximumFileSizeLimitInByte
|
|
923
972
|
}
|
|
924
973
|
},
|
|
925
|
-
use: _module.optimizer.data.loader.map(
|
|
974
|
+
use: _module.optimizer.data.loader.map(createEvaluateMapper('data'))
|
|
926
975
|
}
|
|
927
976
|
// endregion
|
|
928
977
|
};
|