Replace loader for Webpack
Perform replacements (plain and regular expression) in the contents loaded by the loader.
$ npm install --save-dev webpack-replace
Add the loader to your webpack.config.js
:
module.exports = {
// ...
module: {
loaders: [
{
test: /fileInWhichJQueryIsUndefined\.js$/,
loader: 'webpack-replace',
query: {
search: 'jQuery',
replace: 'window.$'
}
}
]
}
}
module.exports = {
// ...
module: {
loaders: [
{
test: /\.js$/,
loader: 'webpack-replace',
query: {
replace: [{
from: 'jQuery',
to: 'window.$'
}]
}
}
]
}
}
Feel free to open issues to propose stuff and participate. Pull requests are also welcome.