Skip to content

Commit

Permalink
Build process update for modules
Browse files Browse the repository at this point in the history
Now __GLOBAL__.exportDefault isn’t needed anymore
Closes #85
  • Loading branch information
dustin-H committed Mar 2, 2016
1 parent f416e55 commit 67f5c83
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ build/*
src/coreModules.js
public/modules/*
public/bundle.js
.moduleCreators
19 changes: 15 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@ var webpack = require('webpack')
var fs = require('fs')

var productionPlugin = new webpack.DefinePlugin({
'process.env.NODE_ENV': '"'+process.env.NODE_ENV+'"'
'process.env.NODE_ENV': '"' + process.env.NODE_ENV + '"'
})

var modulesPath = 'modules'
var modulesPath = __dirname + '/modules'
var moduleCreatorsPath = __dirname + '/.moduleCreators'

var modules = fs.readdirSync(__dirname + '/' + modulesPath)
var modules = fs.readdirSync(modulesPath)
if (modules.indexOf('.DS_Store') >= 0) {
modules.splice(modules.indexOf('.DS_Store'), 1)
}

try {
fs.mkdirSync(moduleCreatorsPath)
} catch ( e ) {}

var config = [{
name: 'bauhaus-ui',
plugins: [productionPlugin],
Expand All @@ -38,11 +43,17 @@ var config = [{

for (var i in modules) {
var name = modules[i]
var modulePath = modulesPath + '/' + name + '/index.js'
//var reqModulePath = modulesPath + '/' + modulePath + '/index.js'
var creatorPath = moduleCreatorsPath + '/' + name + '.js'
var src = '__GLOBAL__.exportDefault = require("' + modulePath + '")'
fs.writeFileSync(creatorPath, src)

config.push({
name: 'bauhaus-ui-' + name,
plugins: [productionPlugin],
context: __dirname + '/',
entry: __dirname + '/' + modulesPath + '/' + name + '/index.js',
entry: creatorPath,
output: {
filename: name + '.js',
path: __dirname + '/public/modules/'
Expand Down

0 comments on commit 67f5c83

Please sign in to comment.