Created
March 17, 2018 22:56
-
-
Save Akryum/53da1c59775cdb4beace2f6189b40205 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { resolve } = require('path') | |
const chalk = require('chalk') | |
const findInFiles = require('find-in-files') | |
const importReg = /'(.*?)'$/ | |
async function findVendorEntries (vendors, folder) { | |
const reg = `import (.*? from )?'((${vendors.join('|')})/.*?)'` | |
const results = await findInFiles.find(reg, folder, /\.(vue|jsx?|styl)$/) | |
const set = new Set(vendors) | |
for (const file in results) { | |
const result = results[file] | |
for (const n in result.matches) { | |
const matches = result.matches[n].match(importReg) | |
if (matches && matches.length > 1) { | |
const p = matches[1] | |
set.add(p) | |
} | |
} | |
} | |
return Array.from(set) | |
} | |
module.exports = { | |
getAlias, | |
formatModule, | |
findVendorEntries, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { findVendorEntries } = require('./utils') | |
module.exports = { | |
plugins: [ | |
new AutoDllPlugin({ | |
path: resolve(__dirname, '../dist/'), | |
filename: '[name].dll.js', | |
entry: { | |
vendor: [ | |
...await findVendorEntries(Object.keys(packageData.dependencies), resolve(__dirname, '../src/')), | |
'core-js', | |
'common/css/vendors', | |
'common/js/vendors', | |
], | |
}, | |
context, | |
debug: true, | |
inherit: true, | |
}), | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment