well, mocha-webpack runs

This commit is contained in:
Devin Howard 2017-03-04 14:32:48 -08:00
parent 137004a47f
commit 79cdb93ee6
4 changed files with 13 additions and 2 deletions

1
.gitignore vendored
View file

@ -22,6 +22,7 @@ app/assets/javascripts/webpacked
# Ignore all logfiles and tempfiles. # Ignore all logfiles and tempfiles.
log/*.log log/*.log
tmp tmp
.tmp
coverage coverage

View file

@ -5,7 +5,7 @@
"scripts": { "scripts": {
"build": "webpack", "build": "webpack",
"build:watch": "webpack --watch", "build:watch": "webpack --watch",
"test": "mocha --compilers js:babel-core/register frontend/test", "test": "mocha-webpack --webpack-config webpack.test.config.js frontend/test",
"eslint": "eslint frontend", "eslint": "eslint frontend",
"eslint:fix": "eslint --fix frontend" "eslint:fix": "eslint --fix frontend"
}, },

View file

@ -5,8 +5,12 @@ const NODE_ENV = process.env.NODE_ENV || 'development'
const plugins = [ const plugins = [
new webpack.DefinePlugin({ new webpack.DefinePlugin({
"process.env.NODE_ENV": `"${NODE_ENV}"` "process.env.NODE_ENV": `"${NODE_ENV}"`
}) }),
new webpack.IgnorePlugin(/^mock-firmata$/), // work around bindings.js error
new webpack.ContextReplacementPlugin(/bindings$/, /^$/) // work around bindings.js error
] ]
const externals = ["bindings"] // work around bindings.js error
if (NODE_ENV === 'production') { if (NODE_ENV === 'production') {
plugins.push(new webpack.optimize.DedupePlugin()) plugins.push(new webpack.optimize.DedupePlugin())
plugins.push(new webpack.optimize.UglifyJsPlugin({ plugins.push(new webpack.optimize.UglifyJsPlugin({
@ -26,6 +30,7 @@ const devtool = NODE_ENV === 'production' ? undefined : 'cheap-module-eval-sourc
module.exports = { module.exports = {
context: __dirname, context: __dirname,
plugins, plugins,
externals,
devtool, devtool,
module: { module: {
preLoaders: [ preLoaders: [

5
webpack.test.config.js Normal file
View file

@ -0,0 +1,5 @@
const config = require('./webpack.config')
config.target = 'node'
module.exports = config