39 lines
969 B
JavaScript
39 lines
969 B
JavaScript
require('require-yaml');
|
|
|
|
/**
|
|
* Obtains the webpack asset filenames with its hash.
|
|
*
|
|
* @param {String} main The main asset name
|
|
* @param {Array} deps The main asset dependencies
|
|
* @return {Array} The assets filenames
|
|
*/
|
|
function assets(main, deps) {
|
|
let jsFiles;
|
|
let env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
|
|
|
|
if (env === 'development') {
|
|
const wpConfig = require('../../../webpack.config.yml');
|
|
let publicPath = wpConfig.publicPath;
|
|
|
|
jsFiles = [`${publicPath}/manifest.js`];
|
|
|
|
for (let dep of deps)
|
|
jsFiles.push(`${publicPath}/${dep}.js`);
|
|
|
|
jsFiles.push(`${publicPath}/${main}.js`);
|
|
} else {
|
|
const wpAssets = require('./webpack-assets.json');
|
|
|
|
let jsFiles = [wpAssets.manifest.js];
|
|
|
|
for (let dep of deps)
|
|
jsFiles.push(wpAssets[dep].js);
|
|
|
|
jsFiles.push(wpAssets[main].js);
|
|
}
|
|
|
|
return jsFiles;
|
|
}
|
|
|
|
module.exports = assets;
|