Skip to content

Instantly share code, notes, and snippets.

@gauravtiwari

gauravtiwari/shared.js

Last active Feb 22, 2017
Embed
What would you like to do?
Shared webpack config
// Note: You must restart bin/webpack-watcher for changes to take effect
var path = require('path');
var glob = require('glob');
var extname = require('path-complete-extname');
var distPath = process.env.WEBPACK_DIST_PATH;
if (distPath === undefined) {
distPath = 'packs'
}
var config = {
entry: glob.sync(path.resolve('app', 'javascript', 'packs', '*.js*')).reduce(
function(map, entry) {
basename = path.basename(entry, extname(entry))
map[basename] = path.resolve(entry);
return map;
}, {}
),
output: { filename: '[name].js', path: path.resolve('public', distPath) },
module: {
rules: [
{ test: /\.coffee(.erb)?$/, loader: 'coffee-loader' },
{
test: /\.jsx?(.erb)?$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
presets: [
'react', ['latest', { 'es2015': { 'modules': false } }],
['env', { "modules": false }],
],
}
},
{
test: /\.erb$/,
enforce: 'pre',
loader: 'rails-erb-loader',
options: {
runner: 'bin/rails runner'
}
},
{
test: /\.sass$/,
loader: ['style-loader', 'css-loader', 'sass-loader'],
},
]
},
plugins: [],
resolve: {
alias: {
'ie': 'component-ie',
},
extensions: [ '.js', '.coffee' ],
modules: [
path.resolve('app/javascript'),
path.resolve('node_modules')
]
},
resolveLoader: {
modules: [ path.resolve('node_modules') ]
}
}
module.exports = {
distPath: distPath,
config: config
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.