Skip to content

Instantly share code, notes, and snippets.

@mischkl
Last active March 10, 2017 15:18
Show Gist options
  • Save mischkl/a7a1db5c5e89da0e5ffd536d81a42283 to your computer and use it in GitHub Desktop.
Save mischkl/a7a1db5c5e89da0e5ffd536d81a42283 to your computer and use it in GitHub Desktop.
karma-webpack
var webpackConfig = require('./webpack.test.config');
module.exports = function (config) {
config.set({
basePath: './',
files: [
'app/index.ts',
'app/**/*.html',
'test/karma/test_index.ts',
'test/mock/**/*.json'
],
frameworks: ['source-map-support', 'jasmine', 'fixture'],
browsers: ['PhantomJS'],
preprocessors: {
'**/*.html': 'ng-html2js',
'**/*.json': 'json_fixtures',
'app/index.ts': ['webpack', 'sourcemap'],
'test/karma/test_index.ts': ['webpack', 'sourcemap']
},
reporters: ['progress', 'junit', 'coverage'],
logLevel: config.LOG_INFO,
singleRun: false,
junitReporter: {
outputDir: 'target/surefire-reports',
suite: ''
},
coverageReporter: {
dir: 'target/coverage/',
reporters: [
{ type: 'cobertura', subdir: '.', file: 'cobertura.xml'},
{ type: 'lcov', subdir: '.', file: 'lcov.info'}
]
},
ngHtml2JsPreprocessor: {
stripPrefix: 'app/',
moduleName: 'template'
},
jsonFixturesPreprocessor:{
variableName: '__json__'
},
webpack: webpackConfig,
webpackMiddleware: { noInfo: true },
browserNoActivityTimeout: 100000
});
};
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"allowJs": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "dist/ts",
"lib": [
"dom",
"es2016"
]
},
"include": [
"app/**/*.ts",
"typings.d.ts"
],
"exclude": [
"node_modules"
],
"compileOnSave": false,
"buildOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
'app': './app/index'
},
output: {
path: __dirname + '/dist',
filename: '[name]-[hash].js'
},
resolve: {
extensions: ['.js', '.ts'],
modules: ['node_modules']
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: ['awesome-typescript-loader']
},
{
test: /\.js$/,
exclude: /node_modules/,
use: [{loader: 'babel-loader', options: {presets: ['es2016']}}]
}
{
test: /\.json$/,
use: ['raw-loader']
},
{
test: /\.html$/,
use: [{loader: 'html-loader', options: {removeRedundantAttributes: false}}]
},
{
test: /\.scss$/,
use: ['ignore-loader']
},
{
test: /\.(png|jpg)$/,
use: ['url-loader']
},
{
test: /\.(eot|woff|woff2|ttf)$/,
use: ['url-loader']
}
]
},
plugins: [
new HtmlWebpackPlugin({
inject: false,
template: './app/index.ejs'
})
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment