-
-
Save asimpson/e3d5d9c6ea8ab8a68afa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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