Skip to content

Commit

Permalink
chore: update pkgs step-2, upgrading configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ghassanmas committed Mar 7, 2023
1 parent 772fa55 commit 22b3b53
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 44 deletions.
4 changes: 2 additions & 2 deletions common/static/common/js/karma.common.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var webpackConfig = require(path.join(appRoot, 'webpack.dev.config.js'));
// https://github.com/webpack-contrib/karma-webpack/issues/24#issuecomment-257613167
//
// This should be fixed in v3 of karma-webpack
var commonsChunkPluginIndex = webpackConfig[0].plugins.findIndex(function(plugin) { return plugin.chunkNames; });
// var commonsChunkPluginIndex = webpackConfig[0].plugins.findIndex(function(plugin) { return plugin.chunkNames; });

// Files which are needed by all lms/cms suites.
var commonFiles = {
Expand All @@ -79,7 +79,7 @@ var commonFiles = {
]
};

webpackConfig[0].plugins.splice(commonsChunkPluginIndex, 1);
// webpackConfig[0].plugins.splice(commonsChunkPluginIndex, 1);

delete webpackConfig[0].entry;

Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"karma-selenium-webdriver-launcher": "git+https://github.com/PSpSynedra/karma-selenium-webdriver-launcher",
"karma-sourcemap-loader": "0.3.7",
"karma-spec-reporter": "0.0.20",
"karma-webpack": "4.0.0",
"karma-webpack": "4.0.2",
"plato": "1.7.0",
"react-test-renderer": "16.4.0",
"selenium-webdriver": "3.6.0",
Expand Down
7 changes: 2 additions & 5 deletions webpack.common.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ var workerConfig = function() {
path: process.env.STATIC_ROOT_LMS,
filename: 'webpack-worker-stats.json'
}),
new webpack.DefinePlugin({
'process.env.JS_ENV_EXTRA_CONFIG': JSON.parse(process.env.JS_ENV_EXTRA_CONFIG),
})
],
module: {
rules: [
Expand Down Expand Up @@ -131,8 +128,6 @@ module.exports = Merge.smart({
},

plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.NamedModulesPlugin(),
new BundleTracker({
path: process.env.STATIC_ROOT_CMS,
filename: 'webpack-stats.json'
Expand Down Expand Up @@ -162,13 +157,15 @@ module.exports = Merge.smart({
// recommended workaround, as this plugin is just an optimization. But
// because of this, we really don't want to get too fancy with how we
// invoke this plugin until we can upgrade karma-webpack.
/*
new webpack.optimize.CommonsChunkPlugin({
// If the value below changes, update the render_bundle call in
// common/djangoapps/pipeline_mako/templates/static_content.html
name: 'commons',
filename: 'commons.js',
minChunks: 10
})
*/
],

module: {
Expand Down
10 changes: 6 additions & 4 deletions webpack.dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ module.exports = _.values(Merge.smart(commonConfig, {
loader: 'sass-loader',
options: {
data: '$base-rem-size: 0.625; @import "paragon-reset";',
includePaths: [
path.join(__dirname, './node_modules/@edx/paragon/src/utils'),
path.join(__dirname, './node_modules/')
],
sassOptions: {
includePaths: [
path.join(__dirname, './node_modules/@edx/paragon/src/utils'),
path.join(__dirname, './node_modules/')
],
},
sourceMap: true
}
}
Expand Down
37 changes: 12 additions & 25 deletions webpack.prod.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,22 @@ var commonConfig = require('./webpack.common.config.js');
var optimizedConfig = Merge.smart(commonConfig, {
web: {
output: {
filename: '[name].[chunkhash].js'
filename: '[name].[chunkhash].min.js'
},
devtool: false,
optimization: {
runtimeChunk: 'single',
splitChunks: {
chunks: 'all',
},
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
'process.env.JS_ENV_EXTRA_CONFIG': process.env.JS_ENV_EXTRA_CONFIG
}),
new webpack.LoaderOptionsPlugin({ // This may not be needed; legacy option for loaders written for webpack 1
minimize: true
}),
new webpack.optimize.UglifyJsPlugin(),
new webpack.optimize.CommonsChunkPlugin({
// If the value below changes, update the render_bundle call in
// common/djangoapps/pipeline_mako/templates/static_content.html
name: 'commons',
filename: 'commons.[chunkhash].js',
minChunks: 3
})
]
}});
}
});

// requireCompatConfig only exists so that you can use RequireJS to require a
// Webpack bundle (but try not to do that if you can help it). RequireJS knows
Expand All @@ -51,17 +46,9 @@ var requireCompatConfig = Merge.smart(optimizedConfig, {
web: {
output: {
filename: '[name].js'
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
// If the value below changes, update the render_bundle call in
// common/djangoapps/pipeline_mako/templates/static_content.html
name: 'commons',
filename: 'commons.js',
minChunks: 3
})
]
}});
}
}
});

// Step 2: Remove the plugin entries that generate the webpack-stats.json files
// that Django needs to look up resources. We never want to accidentally
Expand Down

0 comments on commit 22b3b53

Please sign in to comment.