Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove webpack-inject-plugin dependency #464

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 1 addition & 4 deletions Resources/package.json
Expand Up @@ -34,8 +34,8 @@
"google-closure-library": "^20220104.0.0",
"gulp": "^4.0.2",
"gulp-rename": "^2.0.0",
"gulp-uglify": "^3.0.2",
"gulp-typescript": "^6.0.0-alpha.1",
"gulp-uglify": "^3.0.2",
"gulp-wrap": "^0.15.0",
"jasmine": "^4.0.2",
"tsd": "^0.19.1",
Expand All @@ -47,8 +47,5 @@
"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"
}
}
19 changes: 12 additions & 7 deletions Resources/webpack/FosRouting.js
Expand Up @@ -4,8 +4,7 @@
const fs = require('fs');
const path = require('path');
const util = require('util');

const InjectPlugin = require('webpack-inject-plugin').default;
const webpack = require("webpack");

const execFile = util.promisify(require('child_process').execFile);
const readFile = util.promisify(fs.readFile);
Expand Down Expand Up @@ -90,11 +89,17 @@ class FosRouting {
}
});

new InjectPlugin(() => {
return 'import Routing from "fos-router";' +
'import routes from '+JSON.stringify(this.finalTarget)+';' +
'Routing.setRoutingData(routes);';
}).apply(compiler);
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);
}
}

Expand Down