Skip to content

Instantly share code, notes, and snippets.

@JeroenVinke
Last active July 21, 2017 09:13
Show Gist options
  • Select an option

  • Save JeroenVinke/c4c9fcb2d82a0370d2e153ed84ab0289 to your computer and use it in GitHub Desktop.

Select an option

Save JeroenVinke/c4c9fcb2d82a0370d2e153ed84ab0289 to your computer and use it in GitHub Desktop.
// Karma configuration
// Generated on Fri Dec 05 2014 16:49:29 GMT-0500 (EST)
module.exports = function(config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '',
frameworks: ['jasmine'],
files: [
{pattern: 'test/unit/**/*.spec.js', watched: false}
],
preprocessors: {
// add webpack as preprocessor
'test/unit/**/*.spec.js': ['webpack']
},
// list of files to exclude
exclude: [],
webpack: require('./webpack.config.js')({ coverage: false }),
webpackServer: { noInfo: true },
// 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: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.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'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
});
};
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { AureliaPlugin } = require('aurelia-webpack-plugin');
// config helpers:
const ensureArray = (config) => config && (Array.isArray(config) ? config : [config]) || []
const when = (condition, config, negativeConfig) =>
condition ? ensureArray(config) : ensureArray(negativeConfig)
// primary config:
const outDir = path.resolve(__dirname, 'dist');
const srcDir = path.resolve(__dirname, 'src');
const nodeModulesDir = path.resolve(__dirname, 'node_modules');
const baseUrl = '/';
const cssRules = [
{ loader: 'css-loader' }
]
module.exports = () => ({
resolve: {
extensions: ['.js'],
modules: [srcDir, 'node_modules'],
},
entry: {
app: ['aurelia-bootstrapper']
},
module: {
rules: [
// CSS required in JS/TS files should use the style-loader that auto-injects it into the website
// only when the issuer is a .js/.ts file, so the loaders are not applied inside html templates
{
test: /\.css$/i,
issuer: [{ not: [{ test: /\.html$/i }] }],
use: ['style-loader', ...cssRules],
},
{
test: /\.css$/i,
issuer: [{ test: /\.html$/i }],
// CSS required in templates cannot be extracted safely
// because Aurelia would try to require it again in runtime
use: cssRules,
},
{ test: /\.html$/i, loader: 'html-loader' },
{ test: /\.js$/i, loader: 'babel-loader', exclude: nodeModulesDir,
options: {},
},
{ test: /\.json$/i, loader: 'json-loader' }
]
},
plugins: [
new AureliaPlugin({ aureliaApp: undefined })
],
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment