Skip to content

Instantly share code, notes, and snippets.

@flarnie
Last active January 8, 2016 05:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flarnie/40373870c8eef92bc43f to your computer and use it in GitHub Desktop.
Save flarnie/40373870c8eef92bc43f to your computer and use it in GitHub Desktop.
Webpack configuration file for Rails setup
/**
* @see http://webpack.github.io/docs/configuration.html
* for webpack configuration options
*/
module.exports = {
// 'context' sets the directory where webpack looks for module files you list in
// your 'require' statements
context: __dirname + '/app/assets/javascripts',
// 'entry' specifies the entry point, where webpack starts reading all
// dependencies listed and bundling them into the output file.
// The entrypoint can be anywhere and named anything - here we are calling it
// '_application' and storing it in the 'javascripts' directory to follow
// Rails conventions.
entry: './app/assets/javascripts/_application.js',
// 'output' specifies the filepath for saving the bundled output generated by
// wepback.
// It is an object with options, and you can interpolate the name of the entry
// file using '[name]' in the filename.
// You will want to add the bundled filename to your '.gitignore'.
output: {
filename: '[name].bundle.js',
// We want to save the bundle in the same directory as the other JS.
path: __dirname + '/app/assets/javascripts',
},
// The 'module' and 'loaders' options tell webpack to use loaders.
// @see http://webpack.github.io/docs/using-loaders.html
module: {
loaders: [
{
// Pattern to match only files with the '.js' or '.jsx' extension.
// This tells the loader to only run for those files.
test: /\.jsx?$/,
// @see https://github.com/shama/es6-loader
// It was installed with 'npm install es6-loader --save' and transpiles
// es6 to es5.
loader: 'es6-loader'
}
]
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment