Skip to content

Instantly share code, notes, and snippets.

@dreadjr
Forked from wonderbeyond/webpack.config.js
Created July 26, 2016 07:24
Show Gist options
  • Save dreadjr/bc47f4bf6760f4a23521c0673527fc74 to your computer and use it in GitHub Desktop.
Save dreadjr/bc47f4bf6760f4a23521c0673527fc74 to your computer and use it in GitHub Desktop.
webpack config for our complex RequireJS code base
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