weboptimizer 2.0.1562 → 2.0.1564
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 +2 -2
- package/webpackConfigurator.js +92 -39
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weboptimizer",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1564",
|
|
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",
|
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,35 @@ 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
|
-
options: _module.preprocessor.ejs.options || {}
|
|
702
|
-
|
|
714
|
+
options: (0, _clientnode.extend)(true, _module.preprocessor.ejs.options || {}, {
|
|
715
|
+
compress: {
|
|
716
|
+
html: false
|
|
717
|
+
}
|
|
718
|
+
})
|
|
719
|
+
}, _module.preprocessor.ejs.additional.post.map(createEvaluateMapper('ejs')))
|
|
703
720
|
},
|
|
704
721
|
// endregion
|
|
705
722
|
// region script
|
|
706
723
|
script: {
|
|
707
724
|
exclude: function exclude(filePath) {
|
|
708
|
-
return evaluateAnThrow(_module.preprocessor.javaScript.exclude,
|
|
725
|
+
return evaluateAnThrow(_module.preprocessor.javaScript.exclude, {
|
|
726
|
+
filePath: filePath,
|
|
727
|
+
type: 'script'
|
|
728
|
+
});
|
|
709
729
|
},
|
|
710
730
|
include: function include(filePath) {
|
|
711
|
-
var result = evaluateAnThrow(_module.preprocessor.javaScript.include,
|
|
731
|
+
var result = evaluateAnThrow(_module.preprocessor.javaScript.include, {
|
|
732
|
+
filePath: filePath,
|
|
733
|
+
type: 'script'
|
|
734
|
+
});
|
|
712
735
|
if ([null, undefined].includes(result)) {
|
|
713
736
|
var _iterator10 = _createForOfIteratorHelper(getIncludingPaths(configuration.path.source.asset.javaScript)),
|
|
714
737
|
_step10;
|
|
@@ -727,10 +750,10 @@ var genericLoader = {
|
|
|
727
750
|
return Boolean(result);
|
|
728
751
|
},
|
|
729
752
|
test: new RegExp(_module.preprocessor.javaScript.regularExpression, 'i'),
|
|
730
|
-
use: _module.preprocessor.javaScript.additional.pre.map(
|
|
753
|
+
use: _module.preprocessor.javaScript.additional.pre.map(createEvaluateMapper('script')).concat({
|
|
731
754
|
loader: _module.preprocessor.javaScript.loader,
|
|
732
755
|
options: _module.preprocessor.javaScript.options || {}
|
|
733
|
-
}, _module.preprocessor.javaScript.additional.post.map(
|
|
756
|
+
}, _module.preprocessor.javaScript.additional.post.map(createEvaluateMapper('script')))
|
|
734
757
|
},
|
|
735
758
|
// endregion
|
|
736
759
|
// region html template
|
|
@@ -744,11 +767,14 @@ var genericLoader = {
|
|
|
744
767
|
exclude: function exclude(filePath) {
|
|
745
768
|
return (0, _helper.normalizePaths)(configuration.files.html.concat(configuration.files.defaultHTML).map(function (htmlConfiguration) {
|
|
746
769
|
return htmlConfiguration.template.filePath;
|
|
747
|
-
})).includes(filePath) || (_module.preprocessor.html.exclude === null ? false : evaluateAnThrow(_module.preprocessor.html.exclude,
|
|
770
|
+
})).includes(filePath) || (_module.preprocessor.html.exclude === null ? false : evaluateAnThrow(_module.preprocessor.html.exclude, {
|
|
771
|
+
filePath: filePath,
|
|
772
|
+
type: 'html.ejs'
|
|
773
|
+
}));
|
|
748
774
|
},
|
|
749
775
|
include: configuration.path.source.asset.template,
|
|
750
776
|
test: /\.html\.ejs(?: \?.*)?$/i,
|
|
751
|
-
use: _module.preprocessor.html.additional.pre.map(
|
|
777
|
+
use: _module.preprocessor.html.additional.pre.map(createEvaluateMapper('html.ejs')).concat(
|
|
752
778
|
/*
|
|
753
779
|
We might need to evaluate ejs before we are able to
|
|
754
780
|
parse html beforhand. If not we parse it as html
|
|
@@ -765,24 +791,27 @@ var genericLoader = {
|
|
|
765
791
|
}], {
|
|
766
792
|
loader: _module.preprocessor.html.loader,
|
|
767
793
|
options: _module.preprocessor.html.options || {}
|
|
768
|
-
}, _module.preprocessor.html.additional.post.map(
|
|
794
|
+
}, _module.preprocessor.html.additional.post.map(createEvaluateMapper('html.ejs')))
|
|
769
795
|
},
|
|
770
796
|
html: {
|
|
771
797
|
exclude: function exclude(filePath) {
|
|
772
798
|
return (0, _helper.normalizePaths)(configuration.files.html.concat(configuration.files.defaultHTML).map(function (htmlConfiguration) {
|
|
773
799
|
return htmlConfiguration.template.filePath;
|
|
774
|
-
})).includes(filePath) || (_module.html.exclude === null ? true : evaluateAnThrow(_module.html.exclude,
|
|
800
|
+
})).includes(filePath) || (_module.html.exclude === null ? true : evaluateAnThrow(_module.html.exclude, {
|
|
801
|
+
filePath: filePath,
|
|
802
|
+
type: 'html'
|
|
803
|
+
}));
|
|
775
804
|
},
|
|
776
805
|
include: configuration.path.source.asset.template,
|
|
777
806
|
test: /\.html(?: \?.*)?$/i,
|
|
778
|
-
use: _module.html.additional.pre.map(
|
|
807
|
+
use: _module.html.additional.pre.map(createEvaluateMapper('html')).concat({
|
|
779
808
|
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
809
|
}, {
|
|
781
810
|
loader: 'extract'
|
|
782
811
|
}, {
|
|
783
812
|
loader: _module.html.loader,
|
|
784
813
|
options: _module.html.options || {}
|
|
785
|
-
}, _module.html.additional.post.map(
|
|
814
|
+
}, _module.html.additional.post.map(createEvaluateMapper('html')))
|
|
786
815
|
}
|
|
787
816
|
},
|
|
788
817
|
// endregion
|
|
@@ -790,10 +819,16 @@ var genericLoader = {
|
|
|
790
819
|
// region style
|
|
791
820
|
style: {
|
|
792
821
|
exclude: function exclude(filePath) {
|
|
793
|
-
return _module.cascadingStyleSheet.exclude === null ? isFilePathInDependencies(filePath) : evaluateAnThrow(_module.cascadingStyleSheet.exclude,
|
|
822
|
+
return _module.cascadingStyleSheet.exclude === null ? isFilePathInDependencies(filePath) : evaluateAnThrow(_module.cascadingStyleSheet.exclude, {
|
|
823
|
+
filePath: filePath,
|
|
824
|
+
type: 'style'
|
|
825
|
+
});
|
|
794
826
|
},
|
|
795
827
|
include: function include(filePath) {
|
|
796
|
-
var result = evaluateAnThrow(_module.cascadingStyleSheet.include,
|
|
828
|
+
var result = evaluateAnThrow(_module.cascadingStyleSheet.include, {
|
|
829
|
+
filePath: filePath,
|
|
830
|
+
type: 'style'
|
|
831
|
+
});
|
|
797
832
|
if ([null, undefined].includes(result)) {
|
|
798
833
|
var _iterator11 = _createForOfIteratorHelper(getIncludingPaths(configuration.path.source.asset.cascadingStyleSheet)),
|
|
799
834
|
_step11;
|
|
@@ -820,7 +855,10 @@ var genericLoader = {
|
|
|
820
855
|
font: {
|
|
821
856
|
eot: {
|
|
822
857
|
exclude: function exclude(filePath) {
|
|
823
|
-
return _module.optimizer.font.eot.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.eot.exclude,
|
|
858
|
+
return _module.optimizer.font.eot.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.eot.exclude, {
|
|
859
|
+
filePath: filePath,
|
|
860
|
+
type: 'font.eot'
|
|
861
|
+
});
|
|
824
862
|
},
|
|
825
863
|
generator: {
|
|
826
864
|
filename: (0, _path.join)((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset.font), '[name][ext]') + "?".concat(configuration.hashAlgorithm, "=[contenthash]")
|
|
@@ -832,11 +870,14 @@ var genericLoader = {
|
|
|
832
870
|
maxSize: configuration.inPlace.otherMaximumFileSizeLimitInByte
|
|
833
871
|
}
|
|
834
872
|
},
|
|
835
|
-
use: _module.optimizer.font.eot.loader.map(
|
|
873
|
+
use: _module.optimizer.font.eot.loader.map(createEvaluateMapper('font.eot'))
|
|
836
874
|
},
|
|
837
875
|
svg: {
|
|
838
876
|
exclude: function exclude(filePath) {
|
|
839
|
-
return _module.optimizer.font.svg.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.svg.exclude,
|
|
877
|
+
return _module.optimizer.font.svg.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.svg.exclude, {
|
|
878
|
+
filePath: filePath,
|
|
879
|
+
type: 'svg'
|
|
880
|
+
});
|
|
840
881
|
},
|
|
841
882
|
include: configuration.path.source.asset.font,
|
|
842
883
|
generator: {
|
|
@@ -850,11 +891,14 @@ var genericLoader = {
|
|
|
850
891
|
},
|
|
851
892
|
test: /\.svg(?: \?.*)?$/i,
|
|
852
893
|
type: 'asset/resource',
|
|
853
|
-
use: _module.optimizer.font.svg.loader.map(
|
|
894
|
+
use: _module.optimizer.font.svg.loader.map(createEvaluateMapper('font.svg'))
|
|
854
895
|
},
|
|
855
896
|
ttf: {
|
|
856
897
|
exclude: function exclude(filePath) {
|
|
857
|
-
return _module.optimizer.font.ttf.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.ttf.exclude,
|
|
898
|
+
return _module.optimizer.font.ttf.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.ttf.exclude, {
|
|
899
|
+
filePath: filePath,
|
|
900
|
+
type: 'ttf'
|
|
901
|
+
});
|
|
858
902
|
},
|
|
859
903
|
generator: {
|
|
860
904
|
filename: (0, _path.join)((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset.font), '[name][ext]') + "?".concat(configuration.hashAlgorithm, "=[contenthash]")
|
|
@@ -867,11 +911,14 @@ var genericLoader = {
|
|
|
867
911
|
maxSize: configuration.inPlace.otherMaximumFileSizeLimitInByte
|
|
868
912
|
}
|
|
869
913
|
},
|
|
870
|
-
use: _module.optimizer.font.ttf.loader.map(
|
|
914
|
+
use: _module.optimizer.font.ttf.loader.map(createEvaluateMapper('font.ttf'))
|
|
871
915
|
},
|
|
872
916
|
woff: {
|
|
873
917
|
exclude: function exclude(filePath) {
|
|
874
|
-
return _module.optimizer.font.woff.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.woff.exclude,
|
|
918
|
+
return _module.optimizer.font.woff.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.woff.exclude, {
|
|
919
|
+
filePath: filePath,
|
|
920
|
+
type: 'woff'
|
|
921
|
+
});
|
|
875
922
|
},
|
|
876
923
|
generator: {
|
|
877
924
|
filename: (0, _path.join)((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset.font), '[name][ext]') + "?".concat(configuration.hashAlgorithm, "=[contenthash]")
|
|
@@ -883,14 +930,17 @@ var genericLoader = {
|
|
|
883
930
|
maxSize: configuration.inPlace.otherMaximumFileSizeLimitInByte
|
|
884
931
|
}
|
|
885
932
|
},
|
|
886
|
-
use: _module.optimizer.font.woff.loader.map(
|
|
933
|
+
use: _module.optimizer.font.woff.loader.map(createEvaluateMapper('font.woff'))
|
|
887
934
|
}
|
|
888
935
|
},
|
|
889
936
|
// endregion
|
|
890
937
|
// region image
|
|
891
938
|
image: {
|
|
892
939
|
exclude: function exclude(filePath) {
|
|
893
|
-
return _module.optimizer.image.exclude === null ? isFilePathInDependencies(filePath) : evaluateAnThrow(_module.optimizer.image.exclude,
|
|
940
|
+
return _module.optimizer.image.exclude === null ? isFilePathInDependencies(filePath) : evaluateAnThrow(_module.optimizer.image.exclude, {
|
|
941
|
+
filePath: filePath,
|
|
942
|
+
type: 'image'
|
|
943
|
+
});
|
|
894
944
|
},
|
|
895
945
|
generator: {
|
|
896
946
|
filename: (0, _path.join)((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset.image), '[name][ext]') + "?".concat(configuration.hashAlgorithm, "=[contenthash]")
|
|
@@ -903,14 +953,17 @@ var genericLoader = {
|
|
|
903
953
|
maxSize: configuration.inPlace.otherMaximumFileSizeLimitInByte
|
|
904
954
|
}
|
|
905
955
|
},
|
|
906
|
-
use: _module.optimizer.image.loader.map(
|
|
956
|
+
use: _module.optimizer.image.loader.map(createEvaluateMapper('image'))
|
|
907
957
|
},
|
|
908
958
|
// endregion
|
|
909
959
|
// region data
|
|
910
960
|
data: {
|
|
911
961
|
exclude: function exclude(filePath) {
|
|
912
962
|
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,
|
|
963
|
+
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, {
|
|
964
|
+
filePath: filePath,
|
|
965
|
+
type: 'data'
|
|
966
|
+
}));
|
|
914
967
|
},
|
|
915
968
|
generator: {
|
|
916
969
|
filename: (0, _path.join)((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset.data), '[name][ext]') + "?".concat(configuration.hashAlgorithm, "=[contenthash]")
|
|
@@ -922,7 +975,7 @@ var genericLoader = {
|
|
|
922
975
|
maxSize: configuration.inPlace.otherMaximumFileSizeLimitInByte
|
|
923
976
|
}
|
|
924
977
|
},
|
|
925
|
-
use: _module.optimizer.data.loader.map(
|
|
978
|
+
use: _module.optimizer.data.loader.map(createEvaluateMapper('data'))
|
|
926
979
|
}
|
|
927
980
|
// endregion
|
|
928
981
|
};
|