Skip to content

Commit

Permalink
chore(build): Create build system with webpack and babel
Browse files Browse the repository at this point in the history
  • Loading branch information
MikaAK committed Aug 1, 2016
1 parent be1499d commit bfd6603
Show file tree
Hide file tree
Showing 10 changed files with 381 additions and 35 deletions.
11 changes: 11 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"env": {
"development": {
"sourceMaps": "inline"
}
},
"presets": ["es2015", "stage-2"],
"plugins": [
"transform-runtime"
]
}
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
coverage
dist
305 changes: 305 additions & 0 deletions dist/karma-webpack.js

Large diffs are not rendered by default.

57 changes: 25 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
"version": "1.7.0",
"author": "Tobias Koppers @sokra",
"description": "Use webpack with karma",
"license": "MIT",
"homepage": "http://github.com/webpack/karma-webpack",
"main": "dist/karma-webpack.js",
"scripts": {
"lint": "eslint test src",
"pretest": "npm run lint",
"test": "npm run test.unit",
"test.unit": "mocha --compilers js:babel-register --full-trace --check-leaks test/unit",
"test.integration": "npm run build && karma start --single-run",
"travis": "npm run test.unit && npm run test.integration",
"build": "webpack"
},
"repository": {
"type": "git",
"url": "https://github.com/webpack/karma-webpack.git"
},
"peerDependencies": {
"webpack": "^1.4.0 || ^2 || ^2.1.0-beta"
},
Expand All @@ -16,47 +32,24 @@
"devDependencies": {
"babel-cli": "^6.11.4",
"babel-core": "^6.11.4",
"babel-eslint": "^6.1.2",
"babel-loader": "^6.2.4",
"babel-plugin-transform-runtime": "^6.12.0",
"babel-polyfill": "^6.9.1",
"babel-preset-es2015": "^6.9.0",
"babel-preset-stage-2": "^6.11.0",
"babel-register": "^6.11.6",
"chai": "^3.5.0",
"chai-as-promised": "^5.3.0",
"cross-env": "^2.0.0",
"eslint": "^3.1.1",
"eslint-plugin-babel": "^3.3.0",
"istanbul": "^0.4.4",
"json-loader": "^0.5.4",
"karma": "^1.x",
"karma-chrome-launcher": "~1.0.1",
"karma-mocha": "~1.1.1",
"karma-spec-reporter": "~0.0.22",
"mocha": "^2.5.3"
},
"scripts": {
"lint": "eslint test index.js mocha-env-loader.js",
"pretest": "npm run lint",
"test": "npm run test.unit",
"test.unit": "mocha --harmony --full-trace --check-leaks test/unit",
"test.integration": "karma start --single-run",
"travis": "npm run test.unit && npm run test.integration"
},
"babel": {
"presets": [
"es2015"
],
"plugins": [
"transform-runtime"
],
"ignore": "**/*.test.js",
"env": {
"development": {
"sourceMaps": "inline"
}
}
},
"license": "MIT",
"homepage": "http://github.com/webpack/karma-webpack",
"repository": {
"type": "git",
"url": "https://github.com/webpack/karma-webpack.git"
},
"main": "index.js"
"mocha": "^2.5.3",
"webpack": "^2.1.0-beta.20"
}
}
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions test/integration/karma.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = function(config) {

// list of files / patterns to load in the browser
files: [
'test/index.js'
'test/**/*.test.js'
],


Expand Down Expand Up @@ -102,7 +102,7 @@ module.exports = function(config) {
require('karma-mocha'),
require('karma-spec-reporter'),
require('karma-chrome-launcher'),
require('../../')
require('../../dist/karma-webpack')
]
})
}
2 changes: 1 addition & 1 deletion test/unit/es2015Demo.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var assert = require('chai').assert
import {assert} from 'chai'

describe('Array', function() {
describe('#indexOf()', function() {
Expand Down
35 changes: 35 additions & 0 deletions webpack.config.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import path from 'path'
import {name, dependencies, devDependencies} from './package.json'

const rootPath = (nPath) => path.resolve(__dirname, nPath)
const BUILD_PATH = './dist'
const NODE_MODULES = rootPath('node_modules')

const CONFIG = {
entry: './src/karma-webpack.js',
target: 'node',

output: {
path: BUILD_PATH,
filename: 'karma-webpack.js',
library: name,
libraryTarget: 'umd'
},

module: {
loaders: [{
test: /\.json/,
loader: 'json'
}, {
test: /\.js/,
loader: 'babel',
exclude: [NODE_MODULES],
query: {compact: true}
}]
},

externals: Object.keys(dependencies)
.concat(Object.keys(devDependencies))
}

export default CONFIG

0 comments on commit bfd6603

Please sign in to comment.