Skip to content

Commit 91a40c5

Browse files
committed
feat(Webpack): Add istanbul instrumenter loader configuration. File formatting
1 parent fea12cf commit 91a40c5

File tree

1 file changed

+37
-29
lines changed

1 file changed

+37
-29
lines changed
Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,63 @@
1-
const webpack = require("webpack");
2-
const path = require("path");
3-
const HtmlWebpackPlugin = require("html-webpack-plugin");
4-
const DashboardPlugin = require("webpack-dashboard/plugin");
5-
const nodeEnv = process.env.NODE_ENV || "development";
6-
const isProd = nodeEnv === "production";
1+
const webpack = require('webpack')
2+
const path = require('path')
3+
const HtmlWebpackPlugin = require('html-webpack-plugin')
4+
const DashboardPlugin = require('webpack-dashboard/plugin')
5+
const nodeEnv = process.env.NODE_ENV || 'development'
6+
const isProd = nodeEnv === 'production'
77

88
var config = {
9-
devtool: isProd ? "hidden-source-map" : "source-map",
10-
context: path.resolve("./src"),
9+
devtool: isProd ? 'hidden-source-map' : 'source-map',
10+
context: path.resolve('./src'),
1111
entry: {
12-
app: "./index.ts",
13-
vendor: "./vendor.ts"
12+
app: './index.ts',
13+
vendor: './vendor.ts'
1414
},
1515
output: {
16-
path: path.resolve("./dist"),
17-
filename: "[name].bundle.js",
18-
sourceMapFilename: "[name].bundle.map",
19-
devtoolModuleFilenameTemplate: function (info) {
20-
return "file:///" + info.absoluteResourcePath;
16+
path: path.resolve('./dist'),
17+
filename: '[name].bundle.js',
18+
sourceMapFilename: '[name].bundle.map',
19+
devtoolModuleFilenameTemplate: function(info) {
20+
return 'file:///' + info.absoluteResourcePath
2121
}
2222
},
2323
module: {
2424
rules: [
2525
{
26-
enforce: "pre",
26+
enforce: 'pre',
2727
test: /\.ts?$/,
28-
exclude: ["node_modules"],
29-
use: ["awesome-typescript-loader", "source-map-loader"]
28+
exclude: ['node_modules'],
29+
use: ['awesome-typescript-loader', 'source-map-loader']
3030
},
31-
{ test: /\.html$/, loader: "html-loader" },
32-
{ test: /\.css$/, loaders: ["style-loader", "css-loader"] }
31+
{
32+
test: /\.(js|ts)$/,
33+
loader: 'istanbul-instrumenter-loader',
34+
exclude: [/\/node_modules\//],
35+
query: {
36+
esModules: true
37+
}
38+
},
39+
{ test: /\.html$/, loader: 'html-loader' },
40+
{ test: /\.css$/, loaders: ['style-loader', 'css-loader'] }
3341
]
3442
},
3543
resolve: {
36-
extensions: [".ts", ".js"]
44+
extensions: ['.ts', '.js']
3745
},
3846
plugins: [
3947
new webpack.DefinePlugin({
40-
"process.env": {
48+
'process.env': {
4149
// eslint-disable-line quote-props
4250
NODE_ENV: JSON.stringify(nodeEnv)
4351
}
4452
}),
4553
new HtmlWebpackPlugin({
46-
title: "Typescript Webpack Starter",
47-
template: "!!ejs-loader!src/index.html"
54+
title: 'Typescript Webpack Starter',
55+
template: '!!ejs-loader!src/index.html'
4856
}),
4957
new webpack.optimize.CommonsChunkPlugin({
50-
name: "vendor",
58+
name: 'vendor',
5159
minChunks: Infinity,
52-
filename: "vendor.bundle.js"
60+
filename: 'vendor.bundle.js'
5361
}),
5462
new webpack.optimize.UglifyJsPlugin({
5563
compress: { warnings: false },
@@ -67,11 +75,11 @@ var config = {
6775
})
6876
],
6977
devServer: {
70-
contentBase: path.join(__dirname, "dist/"),
78+
contentBase: path.join(__dirname, 'dist/'),
7179
compress: true,
7280
port: 3000,
7381
hot: true
7482
}
75-
};
83+
}
7684

77-
module.exports = config;
85+
module.exports = config

0 commit comments

Comments
 (0)