Closed Blackbaud-JasonBodnar closed 10 months ago
Why do you want to use production mode?
I want to test the resulting js file. The plan was to add a script tag to the test document dom and set the src to the js file. I'd prefer to do it with the production js file.
As karma is now deprecated and coming up on EOL, we are no longer planning on any significant enhancements to this project and are instead going to focus on security updates, stability, and a migration path forward as karma's lifecycle comes to an end.
Thank you for supporting and using this project!
My
webpack.config.js
:When I run
npx webpack build
, as expected I get:My
karma.config.js
:const path = require('path');
module.exports = { mode: "production", entry: './src/index.tsx', output: { clean: true,
}, module: { rules: [ { test: /.tsx?$/, use: 'ts-loader', exclude: /node_modules/, }, { test: /.s[ac]ss$/i, use: [ // Creates
style
nodes from JS strings "style-loader", // Translates CSS into CommonJS "css-loader", // Compiles Sass to CSS "sass-loader", ], } ], }, resolve: { extensions: ['.tsx', 'css'], } };$ ls dist/bundles/ main.js
const webpackConfig = require('./webpack.config.js'); delete webpackConfig.entry; webpackConfig.mode = 'production';
module.exports = function (config) { 'use strict';
config.set({ frameworks: ['webpack', 'jasmine', 'karma-typescript', 'mocha'], files: [ { pattern: 'src//*.tsx', included: false }, 'src/*/.ts', { pattern: 'dist//*.js', included: false } ], preprocessors: { './src/index.tsx': 'webpack', '*/.ts': 'karma-typescript', }, reporters: ['mocha', 'karma-typescript'], singleRun: true, webpack: webpackConfig }); };
$ ls dist/bundles/ commons.js index.5926340.js runtime.js
When I run
npx karma start
I get:Why does karma-webpack not respect the production mode in the webpack config? I've also tried leaving it out and adding
webpackConfig.mode = 'production
to the karma config (which I how I'd prefer to do it) but that doesn't work either.