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

Commit 9077a59

Browse files
committed
fix(build): Re-init after fixing webpack / karma config copying issues.
1 parent fb8b65d commit 9077a59

File tree

3 files changed

+138
-0
lines changed

3 files changed

+138
-0
lines changed

karma.conf.js

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
const webpackConfig = require('./webpack.config');
2+
const sauceBrowsers = require('./sauce.browsers');
3+
4+
module.exports = function (config) {
5+
// list of files / patterns to load in the browser
6+
// all dependancies should be traced through here
7+
var files = ['test/unit.js'];
8+
9+
// preprocess matching files before serving them to the browser
10+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
11+
// webpack will trace and watch all dependancies
12+
var preprocessors = {
13+
'test/unit.js': [ 'webpack', 'sourcemap' ]
14+
};
15+
16+
if (process.argv.indexOf('--perf') > -1) {
17+
files = [ require.resolve('../benchmark/benchmark.js'), 'test/perf.js' ];
18+
preprocessors = {
19+
'test/perf.js': [ 'webpack', 'sourcemap' ]
20+
};
21+
}
22+
23+
config.set(Object.assign({
24+
// base path that will be used to resolve all patterns (eg. files, exclude)
25+
// setting to process.cwd will make all paths start in current component directory
26+
basePath: process.cwd(),
27+
28+
// frameworks to use
29+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
30+
frameworks: [ 'mocha', 'chai', 'sinon-chai' ],
31+
32+
// list of files / patterns to load in the browser
33+
files: files,
34+
35+
// list of files to exclude
36+
exclude: [],
37+
38+
// list of preprocessors
39+
preprocessors: preprocessors,
40+
41+
// karma watches the test entry points
42+
// (you don't need to specify the entry option)
43+
// webpack watches dependencies
44+
webpack: Object.assign({}, webpackConfig, {
45+
devtool: 'inline-source-map',
46+
entry: undefined
47+
}),
48+
49+
// test results reporter to use
50+
// possible values: 'dots', 'progress'
51+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
52+
reporters: [ 'progress' ],
53+
54+
// web server port
55+
port: 9876,
56+
57+
// enable / disable colors in the output (reporters and logs)
58+
colors: true,
59+
60+
// level of logging
61+
// possible values: LOG_DISABLE, LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG
62+
logLevel: config.LOG_INFO,
63+
64+
// enable / disable watching file and executing tests whenever any file changes
65+
autoWatch: true,
66+
67+
// start these browsers
68+
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
69+
browsers: [ 'Chrome', 'Firefox' ],
70+
71+
// Continuous Integration mode
72+
// if true, Karma captures browsers, runs the tests and exits
73+
singleRun: false,
74+
75+
// Concurrency level
76+
// how many browser should be started simultaneous
77+
concurrency: Infinity
78+
}, process.argv.indexOf('--saucelabs') === -1 ? {} : {
79+
sauceLabs: {
80+
testName: 'Unit Tests',
81+
recordScreenshots: false,
82+
connectOptions: { verbose: true }
83+
},
84+
customLaunchers: sauceBrowsers,
85+
browsers: Object.keys(sauceBrowsers),
86+
captureTimeout: 120000,
87+
reporters: [ 'saucelabs', 'dots' ],
88+
autoWatch: false,
89+
concurrency: 5,
90+
client: {}
91+
}));
92+
};

webpack.conf.js

Whitespace-only changes.

webpack.config.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
var camelCase = require('camelcase');
2+
var path = require('path');
3+
var webpack = require('webpack');
4+
var pkg = require(path.join(process.cwd(), 'package.json'));
5+
var shouldMininimize = process.argv.indexOf('--min') !== -1;
6+
var standardConfig = {
7+
entry: {
8+
'dist/bundle.js': './src/index.js'
9+
},
10+
output: {
11+
path: './',
12+
filename: '[name]',
13+
libraryTarget: 'umd',
14+
library: camelCase(pkg.name),
15+
sourceMapFilename: '[file].map'
16+
},
17+
module: {
18+
loaders: [{
19+
test: /\.css$/,
20+
loader: 'style!css'
21+
}, {
22+
test: /\.less$/,
23+
loader: 'style!css!less'
24+
}, {
25+
loader: 'babel-loader',
26+
test: /\.js$/,
27+
query: {
28+
presets: 'babel-preset-es2015'
29+
}
30+
}]
31+
},
32+
plugins: [
33+
new webpack.optimize.UglifyJsPlugin({
34+
include: /\.min\.js$/,
35+
minimize: true
36+
})
37+
]
38+
};
39+
40+
if (shouldMininimize) {
41+
Object.assign(standardConfig.entry, {
42+
'dist/bundle.min.js': './src/index.js'
43+
});
44+
}
45+
46+
module.exports = standardConfig;

0 commit comments

Comments
 (0)