Revision a9861944
Added by Tomer Brisker almost 6 years ago
.eslintignore | ||
---|---|---|
app/**
|
||
vendor/**
|
||
config/webpack.config.js
|
||
webpack/simple_named_modules.js
|
config/webpack.config.js | ||
---|---|---|
var LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
|
||
var pluginUtils = require('../script/plugin_webpack_directories');
|
||
var vendorEntry = require('./webpack.vendor');
|
||
|
||
|
||
var SimpleNamedModulesPlugin = require('../webpack/simple_named_modules');
|
||
|
||
module.exports = env => {
|
||
// must match config.webpack.dev_server.port
|
||
... | ... | |
},
|
||
sourceMap: false
|
||
}),
|
||
new webpack.NamedModulesPlugin(),
|
||
new SimpleNamedModulesPlugin(),
|
||
new webpack.optimize.ModuleConcatenationPlugin(),
|
||
new webpack.optimize.OccurrenceOrderPlugin(),
|
||
new CompressionPlugin()
|
webpack/simple_named_modules.js | ||
---|---|---|
/*
|
||
Simple Named Modules Plugin
|
||
Strips relative path up to node_modules/ from the module ID.
|
||
This allows for consistent module IDs when building webpack bundles from
|
||
differing base paths relative to the node_modules directory.
|
||
|
||
Based on NamedModulesPlugin by Tobias Koppers @sokra, originally licensed under
|
||
MIT License: http://www.opensource.org/licenses/mit-license.php
|
||
*/
|
||
"use strict";
|
||
|
||
class SimpleNamedModulesPlugin {
|
||
constructor(options) {
|
||
this.options = options || {};
|
||
}
|
||
|
||
apply(compiler) {
|
||
compiler.plugin("compilation", (compilation) => {
|
||
compilation.plugin("before-module-ids", (modules) => {
|
||
modules.forEach((module) => {
|
||
if(module.id === null && module.libIdent) {
|
||
module.id = module.libIdent({
|
||
context: this.options.context || compiler.options.context
|
||
});
|
||
if (module.id.includes('node_modules')) {
|
||
module.id = module.id.slice(module.id.indexOf('node_modules'))
|
||
}
|
||
}
|
||
});
|
||
});
|
||
});
|
||
}
|
||
}
|
||
|
||
module.exports = SimpleNamedModulesPlugin;
|
Also available in: Unified diff
Fixes #23924 - Use consistent IDs for modules in webpack
This replaces the NamedModulesPlugin with a simplified version, that
strips the relative path part of the module ID up to the
node_modules/ part. This allows using consistent naming for modules,
even when running the packaging from different directories relative to
the node_modules folder (as is the case, for example, with katello and
foreman).