-
-
Save dreadjr/bc47f4bf6760f4a23521c0673527fc74 to your computer and use it in GitHub Desktop.
webpack config for our complex RequireJS code base
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require('path'); | |
var webpack = require('webpack'); | |
var ModuleReplace = webpack.NormalModuleReplacementPlugin; | |
module.exports = { | |
entry: { | |
'zjs/js/zyb_transfer_launch': 'zjs/js/zyb_transfer_launch.js', | |
}, | |
output: { | |
filename: '[name].js', | |
path: './dist', | |
publicPath: '/static/dist/', | |
}, | |
module: { | |
noParse: [], | |
}, | |
resolve: { | |
// The directory (absolute path) that contains your modules | |
root: [ | |
path.resolve('.'), | |
path.resolve('./app'), | |
path.resolve('./node_modules'), | |
], | |
alias: { | |
backbone: 'lib/backbone/backbone', | |
}, | |
}, | |
// We already loaded these libs globally | |
externals: { | |
avalon: 'avalon', | |
jquery: 'jQuery', | |
underscore: '_', | |
}, | |
plugins: [ | |
// Hack for requirejs's domReady plugin | |
new ModuleReplace(/^(domReady\!)$/, 'lib/null-module'), | |
// Hack for requirejs's text plugin | |
new ModuleReplace(/^text!.+$/, function(ctx) { | |
ctx.request = ctx.request.replace(/text!/, 'raw!'); | |
}), | |
// Hack for requirejs's css plugin | |
new ModuleReplace(/^css!.+$/, function(ctx) { | |
ctx.request = 'style!' + ctx.request; | |
}), | |
// Load es6-promise from npm modules | |
new ModuleReplace(/es6-promise\/es6-promise/, 'es6-promise'), | |
], | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment