Skip to content

Commit

Permalink
feat(Webpack): Add istanbul instrumenter loader configuration. File f…
Browse files Browse the repository at this point in the history
…ormatting
  • Loading branch information
emyann committed Feb 10, 2018
1 parent fea12cf commit 91a40c5
Showing 1 changed file with 37 additions and 29 deletions.
66 changes: 37 additions & 29 deletions packages/cli/template/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,63 @@
const webpack = require("webpack");
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const DashboardPlugin = require("webpack-dashboard/plugin");
const nodeEnv = process.env.NODE_ENV || "development";
const isProd = nodeEnv === "production";
const webpack = require('webpack')
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const DashboardPlugin = require('webpack-dashboard/plugin')
const nodeEnv = process.env.NODE_ENV || 'development'
const isProd = nodeEnv === 'production'

var config = {
devtool: isProd ? "hidden-source-map" : "source-map",
context: path.resolve("./src"),
devtool: isProd ? 'hidden-source-map' : 'source-map',
context: path.resolve('./src'),
entry: {
app: "./index.ts",
vendor: "./vendor.ts"
app: './index.ts',
vendor: './vendor.ts'
},
output: {
path: path.resolve("./dist"),
filename: "[name].bundle.js",
sourceMapFilename: "[name].bundle.map",
devtoolModuleFilenameTemplate: function (info) {
return "file:///" + info.absoluteResourcePath;
path: path.resolve('./dist'),
filename: '[name].bundle.js',
sourceMapFilename: '[name].bundle.map',
devtoolModuleFilenameTemplate: function(info) {
return 'file:///' + info.absoluteResourcePath
}
},
module: {
rules: [
{
enforce: "pre",
enforce: 'pre',
test: /\.ts?$/,
exclude: ["node_modules"],
use: ["awesome-typescript-loader", "source-map-loader"]
exclude: ['node_modules'],
use: ['awesome-typescript-loader', 'source-map-loader']
},
{ test: /\.html$/, loader: "html-loader" },
{ test: /\.css$/, loaders: ["style-loader", "css-loader"] }
{
test: /\.(js|ts)$/,
loader: 'istanbul-instrumenter-loader',
exclude: [/\/node_modules\//],
query: {
esModules: true
}
},
{ test: /\.html$/, loader: 'html-loader' },
{ test: /\.css$/, loaders: ['style-loader', 'css-loader'] }
]
},
resolve: {
extensions: [".ts", ".js"]
extensions: ['.ts', '.js']
},
plugins: [
new webpack.DefinePlugin({
"process.env": {
'process.env': {
// eslint-disable-line quote-props
NODE_ENV: JSON.stringify(nodeEnv)
}
}),
new HtmlWebpackPlugin({
title: "Typescript Webpack Starter",
template: "!!ejs-loader!src/index.html"
title: 'Typescript Webpack Starter',
template: '!!ejs-loader!src/index.html'
}),
new webpack.optimize.CommonsChunkPlugin({
name: "vendor",
name: 'vendor',
minChunks: Infinity,
filename: "vendor.bundle.js"
filename: 'vendor.bundle.js'
}),
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false },
Expand All @@ -67,11 +75,11 @@ var config = {
})
],
devServer: {
contentBase: path.join(__dirname, "dist/"),
contentBase: path.join(__dirname, 'dist/'),
compress: true,
port: 3000,
hot: true
}
};
}

module.exports = config;
module.exports = config

0 comments on commit 91a40c5

Please sign in to comment.