Skip to content

Instantly share code, notes, and snippets.

@asimpson
Last active March 23, 2017 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asimpson/e3d5d9c6ea8ab8a68afa to your computer and use it in GitHub Desktop.
Save asimpson/e3d5d9c6ea8ab8a68afa to your computer and use it in GitHub Desktop.
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