Last active
December 28, 2016 06:54
-
-
Save wonderbeyond/813a822a4fc5cd5a5ef7 to your computer and use it in GitHub Desktop.
webpack 1.x 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: { | |
'index.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