Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Commit

Permalink
fix(build): Re-init after fixing webpack / karma config copying issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
treshugart committed Jun 20, 2016
1 parent fb8b65d commit 9077a59
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 0 deletions.
92 changes: 92 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
const webpackConfig = require('./webpack.config');
const sauceBrowsers = require('./sauce.browsers');

module.exports = function (config) {
// list of files / patterns to load in the browser
// all dependancies should be traced through here
var files = ['test/unit.js'];

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
// webpack will trace and watch all dependancies
var preprocessors = {
'test/unit.js': [ 'webpack', 'sourcemap' ]
};

if (process.argv.indexOf('--perf') > -1) {
files = [ require.resolve('../benchmark/benchmark.js'), 'test/perf.js' ];
preprocessors = {
'test/perf.js': [ 'webpack', 'sourcemap' ]
};
}

config.set(Object.assign({
// base path that will be used to resolve all patterns (eg. files, exclude)
// setting to process.cwd will make all paths start in current component directory
basePath: process.cwd(),

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: [ 'mocha', 'chai', 'sinon-chai' ],

// list of files / patterns to load in the browser
files: files,

// list of files to exclude
exclude: [],

// list of preprocessors
preprocessors: preprocessors,

// karma watches the test entry points
// (you don't need to specify the entry option)
// webpack watches dependencies
webpack: Object.assign({}, webpackConfig, {
devtool: 'inline-source-map',
entry: undefined
}),

// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: [ 'progress' ],

// web server port
port: 9876,

// enable / disable colors in the output (reporters and logs)
colors: true,

// level of logging
// possible values: LOG_DISABLE, LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG
logLevel: config.LOG_INFO,

// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: [ 'Chrome', 'Firefox' ],

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
}, process.argv.indexOf('--saucelabs') === -1 ? {} : {
sauceLabs: {
testName: 'Unit Tests',
recordScreenshots: false,
connectOptions: { verbose: true }
},
customLaunchers: sauceBrowsers,
browsers: Object.keys(sauceBrowsers),
captureTimeout: 120000,
reporters: [ 'saucelabs', 'dots' ],
autoWatch: false,
concurrency: 5,
client: {}
}));
};
Empty file removed webpack.conf.js
Empty file.
46 changes: 46 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
var camelCase = require('camelcase');
var path = require('path');
var webpack = require('webpack');
var pkg = require(path.join(process.cwd(), 'package.json'));
var shouldMininimize = process.argv.indexOf('--min') !== -1;
var standardConfig = {
entry: {
'dist/bundle.js': './src/index.js'
},
output: {
path: './',
filename: '[name]',
libraryTarget: 'umd',
library: camelCase(pkg.name),
sourceMapFilename: '[file].map'
},
module: {
loaders: [{
test: /\.css$/,
loader: 'style!css'
}, {
test: /\.less$/,
loader: 'style!css!less'
}, {
loader: 'babel-loader',
test: /\.js$/,
query: {
presets: 'babel-preset-es2015'
}
}]
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
include: /\.min\.js$/,
minimize: true
})
]
};

if (shouldMininimize) {
Object.assign(standardConfig.entry, {
'dist/bundle.min.js': './src/index.js'
});
}

module.exports = standardConfig;

0 comments on commit 9077a59

Please sign in to comment.