Skip to content

Instantly share code, notes, and snippets.

@asimpson
Last active Mar 23, 2017
Embed
What would you like to do?
var webpack = require('webpack');
var path = require('path');
var globby = require('globby');
var src = './specs/';
var componentPath = path.resolve('./src/components');
var out = './specs/build/';
var specs = {};
var files = globby.sync("./specs/**/*.js")
.filter((x) => {
var fileObj = path.parse(x);
return (fileObj.ext === '.js' && fileObj.dir.search('build|helpers') === -1);
})
.map((x) => {
return x.split('specs/')[1];
})
.forEach((x) => {
var name = path.basename(x, '.js');
//key value list of files to create
specs[name] = `./${x}`;
});
module.exports = {
context: path.join(__dirname, src),
entry: specs,
output: {
path: path.join(__dirname, out),
//creates file in specs/build dir that has same name as source file
filename: "[name].js"
},
resolve: {
root: componentPath,
},
resolveLoader: {
//point the loaders to the node_modules directory
root: path.join(__dirname, "node_modules")
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015']
}
}
]
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment