Skip to content

Commit

Permalink
Make DllReferencePlugin configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Jun 18, 2019
1 parent 5191538 commit 420a259
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 89 deletions.
178 changes: 90 additions & 88 deletions buildtools/webpack.commons.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,105 +4,107 @@ const SassPlugin = require('./webpack.plugin.js');

const devMode = process.env.NODE_ENV !== 'production';

module.exports = function(config) {

const dllPlugin = new webpack.DllReferencePlugin({
manifest: path.resolve(__dirname, '../dist/vendor-manifest.json')
});


const providePlugin = new webpack.ProvidePlugin({
// Make sure that Angular finds jQuery and does not fall back to jqLite
// See https://github.com/webpack/webpack/issues/582
'window.jQuery': 'jquery',
// For Bootstrap
'jQuery': 'jquery',
// For own scripts
$: 'jquery',
});

const babelPresets = [[require.resolve('@babel/preset-env'), {
'targets': {
'browsers': ['last 2 versions', 'Firefox ESR', 'ie 11'],
},
'modules': false,
'loose': true,
}]];

const angularRule = {
test: require.resolve('angular'),
use: {
loader: 'expose-loader',
options: 'angular'
}
};
config = config || {};

// Expose corejs-typeahead as window.Bloodhound
const typeaheadRule = {
test: require.resolve('corejs-typeahead'),
use: {
loader: 'expose-loader',
options: 'Bloodhound'
}
};
const dllPlugin = new webpack.DllReferencePlugin(Object.assign({
manifest: path.resolve(__dirname, '../dist/vendor-manifest.json')
}, config.DllReferencePluginOptions || {}));

const cssRule = {
test: /\.css$/,
use: [
'./buildtools/webpack.scss-loader',
'extract-loader',
'css-loader',
]
};

const sassRule = {
test: /\.scss$/,
use: [{
loader: './buildtools/webpack.scss-loader',
}]
};

const htmlRule = {
test: /\.html$/,
use: 'ejs-loader',
};
const providePlugin = new webpack.ProvidePlugin({
// Make sure that Angular finds jQuery and does not fall back to jqLite
// See https://github.com/webpack/webpack/issues/582
'window.jQuery': 'jquery',
// For Bootstrap
'jQuery': 'jquery',
// For own scripts
$: 'jquery',
});

const svgRule = {
test: /\.svg$/,
use: [
{
loader: 'svg-inline-loader',
options: {
removeSVGTagAttrs: false,
},
const babelPresets = [[require.resolve('@babel/preset-env'), {
'targets': {
'browsers': ['last 2 versions', 'Firefox ESR', 'ie 11'],
},
'./buildtools/svg-viewbox-loader',
'svgo-loader',
]
};
'modules': false,
'loose': true,
}]];

function get_comp(firsts, lasts) {
return (f1, f2) => {
for (const pattern of firsts) {
if (f1.indexOf(pattern) >= 0) {
return -1;
}
if (f2.indexOf(pattern) >= 0) {
return 1;
}
const angularRule = {
test: require.resolve('angular'),
use: {
loader: 'expose-loader',
options: 'angular'
}
for (const pattern of lasts) {
if (f1.indexOf(pattern) >= 0) {
return 1;
}
if (f2.indexOf(pattern) >= 0) {
return -1;
}
};

// Expose corejs-typeahead as window.Bloodhound
const typeaheadRule = {
test: require.resolve('corejs-typeahead'),
use: {
loader: 'expose-loader',
options: 'Bloodhound'
}
return 0;
};
}

module.exports = function() {
const cssRule = {
test: /\.css$/,
use: [
'./buildtools/webpack.scss-loader',
'extract-loader',
'css-loader',
]
};

const sassRule = {
test: /\.scss$/,
use: [{
loader: './buildtools/webpack.scss-loader',
}]
};

const htmlRule = {
test: /\.html$/,
use: 'ejs-loader',
};

const svgRule = {
test: /\.svg$/,
use: [
{
loader: 'svg-inline-loader',
options: {
removeSVGTagAttrs: false,
},
},
'./buildtools/svg-viewbox-loader',
'svgo-loader',
]
};

function get_comp(firsts, lasts) {
return (f1, f2) => {
for (const pattern of firsts) {
if (f1.indexOf(pattern) >= 0) {
return -1;
}
if (f2.indexOf(pattern) >= 0) {
return 1;
}
}
for (const pattern of lasts) {
if (f1.indexOf(pattern) >= 0) {
return 1;
}
if (f2.indexOf(pattern) >= 0) {
return -1;
}
}
return 0;
};
}


const ngeoRule = {
test: /\/ngeo\/(?!node_modules\/).*\.js$/,
Expand Down
1 change: 1 addition & 0 deletions buildtools/webpack.config.dll.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ module.exports = {
sourceMap: true,
}),
],
sideEffects: false,
},
};
7 changes: 6 additions & 1 deletion karma-conf.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const path = require('path');
const webpackMerge = require('webpack-merge');

const webpackConfig = webpackMerge(
Expand All @@ -21,7 +22,11 @@ module.exports = function(config) {

// list of files / patterns to load in the browser
files: [
'test/spec/all.js',
{
pattern: path.resolve(__dirname, 'dist/vendor.js'),
watched: false,
served: true
}, 'test/spec/all.js',
],

// preprocess matching files before serving them to the browser
Expand Down

0 comments on commit 420a259

Please sign in to comment.