Created
November 12, 2015 09:33
-
-
Save renren89/feb236e280b57011c213 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require('babel-core/register'); | |
module.exports = function karmaConfig (config) { | |
config.set({ | |
frameworks: [ | |
'mocha' | |
], | |
reporters: [ | |
'spec', | |
'coverage' | |
], | |
files: [ | |
'node_modules/phantomjs-polyfill/bind-polyfill.js', | |
'tests/**/*_spec.*' | |
], | |
preprocessors: { | |
'tests/**/*_spec.*': ['webpack', 'sourcemap'] | |
}, | |
browsers: [ | |
'PhantomJS' | |
], | |
singleRun: true, | |
coverageReporter: { | |
dir: 'build/coverage/', | |
type: 'html' | |
}, | |
webpack: require('./webpack.config'), | |
webpackMiddleware: { | |
noInfo: true | |
} | |
}); | |
}; |
This file contains hidden or 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 path = require('path'); | |
var webpack = require('webpack'); | |
var merge = require('webpack-merge'); | |
var HtmlwebpackPlugin = require('html-webpack-plugin'); | |
var TARGET = process.env.npm_lifecycle_event; | |
var ROOT_PATH = path.resolve(__dirname); | |
var APP_PATH = path.resolve(ROOT_PATH, 'app'); | |
var BUILD_PATH = path.resolve(ROOT_PATH, 'build'); | |
var TEST_PATH = path.resolve(ROOT_PATH, 'tests'); | |
process.env.BABEL_ENV = TARGET; | |
var common = { | |
entry: APP_PATH, | |
resolve: { | |
extensions: ['', '.js', '.jsx'] | |
}, | |
module: { | |
loaders: [ | |
{ | |
test: /\.jsx?$/, | |
loaders: ['babel'], | |
include: APP_PATH | |
} | |
] | |
}, | |
plugins: [ | |
new HtmlwebpackPlugin({ | |
title: 'React Setup' | |
}) | |
] | |
}; | |
if (TARGET === 'start' || !TARGET) { | |
module.exports = merge(common, { | |
devtool: 'eval-source-map', | |
devServer: { | |
historyApiFallback: true, | |
inline: true, | |
progress: true, | |
host: process.env.HOST, | |
port: process.env.PORT | |
} | |
}); | |
} | |
if (TARGET === 'test' || TARGET === 'tdd') { | |
module.exports = merge(common, { | |
entry: {}, | |
output: {}, | |
devtool: 'inline-source-map', | |
resolve: { | |
alias: { | |
app: APP_PATH | |
} | |
}, | |
module: { | |
preLoaders: [ | |
{ | |
test: /\.jsx?$/, | |
loaders: ['isparta-instrumenter'], | |
path: APP_PATH | |
} | |
], | |
loaders: [ | |
{ | |
test: /\.jsx?$/, | |
loaders: ['babel'], | |
path: TEST_PATH | |
} | |
] | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment