From abc28597a187747004e567a9d125b8f1a2e9998d Mon Sep 17 00:00:00 2001 From: lboulanger Date: Thu, 9 Aug 2018 15:43:04 +0200 Subject: [PATCH] rajout du plugin webpack 'replace-bundle' pour remplacer les __GPVERSION__ par la version du package (par ex. pour le parametre gp-ol-ext dans les urls des requetes WMTS) --- package.json | 1 + webpack.config.itowns.js | 20 ++++++++++++++++++++ webpack.config.leaflet.js | 26 ++++++++++++++++++++++++++ webpack.config.mix.js | 27 +++++++++++++++++++++++++++ webpack.config.openlayers.js | 20 ++++++++++++++++++++ 5 files changed, 94 insertions(+) diff --git a/package.json b/package.json index 08926bf49..1144b1ce4 100644 --- a/package.json +++ b/package.json @@ -110,6 +110,7 @@ "mocha-webpack": "^1.1.0", "nyc": "^12.0.2", "path": "^0.12.7", + "replace-bundle-webpack-plugin": "^1.0.0", "requirejs": "^2.3.5", "speed-measure-webpack-plugin": "^1.2.2", "string-template": "^1.0.0", diff --git a/webpack.config.itowns.js b/webpack.config.itowns.js index ea5d1c3c1..2864a25e8 100644 --- a/webpack.config.itowns.js +++ b/webpack.config.itowns.js @@ -12,6 +12,7 @@ var DefineWebpackPlugin = webpack.DefinePlugin; var ExtractTextWebPackPlugin = require("extract-text-webpack-plugin"); var BannerWebPackPlugin = webpack.BannerPlugin; var UglifyJsWebPackPlugin = webpack.optimize.UglifyJsPlugin; +var ReplaceWebpackPlugin = require("replace-bundle-webpack-plugin"); var JsDocWebPackPlugin = require("jsdoc-webpack-plugin"); var HandlebarsPlugin = require("./scripts/webpackPlugins/handlebars-plugin"); var HandlebarsLayoutPlugin = require("handlebars-layouts"); @@ -132,6 +133,25 @@ module.exports = env => { ] }, plugins : [ + /** REPLACEMENT DE VALEURS */ + new ReplaceWebpackPlugin( + [ + { + partten : /__GPITOWNSEXTVERSION__/g, + /** replacement de la clef __GPVERSION__ par la version du package */ + replacement : function () { + return pkg.itownsExtVersion; + } + }, + { + partten : /__GPDATE__/g, + /** replacement de la clef __GPDATE__ par la date du build */ + replacement : function () { + return date; + } + } + ] + ), /** GESTION DU LOGGER */ new DefineWebpackPlugin({ __PRODUCTION__ : JSON.stringify(production) diff --git a/webpack.config.leaflet.js b/webpack.config.leaflet.js index f0e3f721c..9f41ccba7 100644 --- a/webpack.config.leaflet.js +++ b/webpack.config.leaflet.js @@ -12,6 +12,7 @@ var DefineWebpackPlugin = webpack.DefinePlugin; var ExtractTextWebPackPlugin = require("extract-text-webpack-plugin"); var BannerWebPackPlugin = webpack.BannerPlugin; var UglifyJsWebPackPlugin = webpack.optimize.UglifyJsPlugin; +var ReplaceWebpackPlugin = require("replace-bundle-webpack-plugin"); var JsDocWebPackPlugin = require("jsdoc-webpack-plugin"); var HandlebarsPlugin = require("./scripts/webpackPlugins/handlebars-plugin"); var HandlebarsLayoutPlugin = require("handlebars-layouts"); @@ -142,6 +143,31 @@ module.exports = env => { ] }, plugins : [ + /** REPLACEMENT DE VALEURS */ + new ReplaceWebpackPlugin( + [ + { + partten : /__GPLEAFLETEXTVERSION__/g, + /** + * replacement de la clef __GPVERSION__ par la version du package + * @returns {String} leafletExtVersion + */ + replacement : function () { + return pkg.leafletExtVersion; + } + }, + { + partten : /__GPDATE__/g, + /** + * replacement de la clef __GPDATE__ par la date du build + * @returns {String} date + */ + replacement : function () { + return date; + } + } + ] + ), /** GESTION DU LOGGER */ new DefineWebpackPlugin({ __PRODUCTION__ : JSON.stringify(production) diff --git a/webpack.config.mix.js b/webpack.config.mix.js index ff7ed3cea..e5f139e09 100644 --- a/webpack.config.mix.js +++ b/webpack.config.mix.js @@ -11,6 +11,7 @@ var DefineWebpackPlugin = webpack.DefinePlugin; var ExtractTextWebPackPlugin = require("extract-text-webpack-plugin"); var BannerWebPackPlugin = webpack.BannerPlugin; var UglifyJsWebPackPlugin = webpack.optimize.UglifyJsPlugin; +var ReplaceWebpackPlugin = require("replace-bundle-webpack-plugin"); // -- performances var SpeedMeasurePlugin = require("speed-measure-webpack-plugin"); @@ -133,6 +134,32 @@ module.exports = env => { ] }, plugins : [ + /** REPLACEMENT DE VALEURS */ + new ReplaceWebpackPlugin( + [ + { + partten : /__GPITOWNSEXTVERSION__/g, + /** replacement de la clef __GPVERSION__ par la version du package */ + replacement : function () { + return pkg.itownsExtVersion; + } + }, + { + partten : /__GPOLEXTVERSION__/g, + /** replacement de la clef __GPVERSION__ par la version du package */ + replacement : function () { + return pkg.olExtVersion; + } + }, + { + partten : /__GPDATE__/g, + /** replacement de la clef __GPDATE__ par la date du build */ + replacement : function () { + return date; + } + } + ] + ), /** GESTION DU LOGGER */ new DefineWebpackPlugin({ __PRODUCTION__ : JSON.stringify(production) diff --git a/webpack.config.openlayers.js b/webpack.config.openlayers.js index b486c8abe..cfdf31da4 100644 --- a/webpack.config.openlayers.js +++ b/webpack.config.openlayers.js @@ -12,6 +12,7 @@ var DefineWebpackPlugin = webpack.DefinePlugin; var ExtractTextWebPackPlugin = require("extract-text-webpack-plugin"); var BannerWebPackPlugin = webpack.BannerPlugin; var UglifyJsWebPackPlugin = webpack.optimize.UglifyJsPlugin; +var ReplaceWebpackPlugin = require("replace-bundle-webpack-plugin"); var JsDocWebPackPlugin = require("jsdoc-webpack-plugin"); var HandlebarsPlugin = require("./scripts/webpackPlugins/handlebars-plugin"); var HandlebarsLayoutPlugin = require("handlebars-layouts"); @@ -141,6 +142,25 @@ module.exports = env => { ] }, plugins : [ + /** REPLACEMENT DE VALEURS */ + new ReplaceWebpackPlugin( + [ + { + partten : /__GPOLEXTVERSION__/g, + /** replacement de la clef __GPVERSION__ par la version du package */ + replacement : function () { + return pkg.olExtVersion; + } + }, + { + partten : /__GPDATE__/g, + /** replacement de la clef __GPDATE__ par la date du build */ + replacement : function () { + return date; + } + } + ] + ), /** GESTION DU LOGGER */ new DefineWebpackPlugin({ __PRODUCTION__ : JSON.stringify(production)