diff --git a/Resources/package.json b/Resources/package.json index 828361e..0d2e198 100755 --- a/Resources/package.json +++ b/Resources/package.json @@ -34,8 +34,8 @@ "google-closure-library": "^20220104.0.0", "gulp": "^4.0.2", "gulp-rename": "^2.0.0", - "gulp-typescript": "^6.0.0-alpha.1", "gulp-uglify": "^3.0.2", + "gulp-typescript": "^6.0.0-alpha.1", "gulp-wrap": "^0.15.0", "jasmine": "^4.0.2", "tsd": "^0.19.1", @@ -47,5 +47,8 @@ "test": "npm run build && npm run test:types && phantomjs js/run_jsunit.js js/router_test.html", "test:types": "tsd", "prepublish": "npm run build" + }, + "dependencies": { + "webpack-inject-plugin": "^1.5.5" } } diff --git a/Resources/webpack/FosRouting.js b/Resources/webpack/FosRouting.js index 1c1a2b8..e99ff1a 100644 --- a/Resources/webpack/FosRouting.js +++ b/Resources/webpack/FosRouting.js @@ -4,7 +4,8 @@ const fs = require('fs'); const path = require('path'); const util = require('util'); -const webpack = require("webpack"); + +const InjectPlugin = require('webpack-inject-plugin').default; const execFile = util.promisify(require('child_process').execFile); const readFile = util.promisify(fs.readFile); @@ -89,17 +90,11 @@ class FosRouting { } }); - new webpack.BannerPlugin({ - entryOnly: true, - include: this.finalTarget ? this.finalTarget + ".js" : /\.js$/, - raw: true, - banner: - 'import Routing from "fos-router";' + - "import routes from " + - JSON.stringify(this.finalTarget) + - ";" + - "Routing.setRoutingData(routes);", - }).apply(compiler); + new InjectPlugin(() => { + return 'import Routing from "fos-router";' + + 'import routes from '+JSON.stringify(this.finalTarget)+';' + + 'Routing.setRoutingData(routes);'; + }).apply(compiler); } }