Skip to content

Instantly share code, notes, and snippets.

@wonderbeyond
Last active December 28, 2016 06:54
Show Gist options
  • Save wonderbeyond/813a822a4fc5cd5a5ef7 to your computer and use it in GitHub Desktop.
Save wonderbeyond/813a822a4fc5cd5a5ef7 to your computer and use it in GitHub Desktop.
webpack 1.x config for our complex RequireJS code base
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