50 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-01-17 13:40:59 +01:00
/*eslint-disable*/
// No need to build the DLL in production
if (process.env.NODE_ENV === 'production') {
2017-05-17 12:01:52 +02:00
process.exit(0);
2017-01-17 13:40:59 +01:00
}
2017-05-17 12:01:52 +02:00
require('shelljs/global');
2017-01-17 13:40:59 +01:00
2017-05-17 12:01:52 +02:00
const path = require('path');
const fs = require('fs');
const exists = fs.existsSync;
const writeFile = fs.writeFileSync;
2017-01-17 13:40:59 +01:00
2017-05-17 12:01:52 +02:00
const defaults = require('lodash/defaultsDeep');
const pkg = require(path.join(process.cwd(), 'package.json'));
const config = require('../config');
const dllConfig = defaults(pkg.dllPlugin, config.dllPlugin.defaults);
const outputPath = path.join(process.cwd(), dllConfig.path);
const dllManifestPath = path.join(outputPath, 'package.json');
2017-01-17 13:40:59 +01:00
/**
2017-05-17 12:01:52 +02:00
* I use node_modules/strapi-plugin-dlls by default just because
2017-01-17 13:40:59 +01:00
* it isn't going to be version controlled and babel wont try to parse it.
*/
2017-05-17 12:01:52 +02:00
mkdir('-p', outputPath);
2017-01-17 13:40:59 +01:00
2017-05-17 12:01:52 +02:00
echo('Building the Webpack DLL...');
2017-01-17 13:40:59 +01:00
/**
* Create a manifest so npm install doesnt warn us
*/
if (!exists(dllManifestPath)) {
writeFile(
dllManifestPath,
JSON.stringify(defaults({
2017-05-17 12:01:52 +02:00
name: 'strapi-plugin-dlls',
2017-01-17 13:40:59 +01:00
private: true,
author: pkg.author,
repository: pkg.repository,
version: pkg.version
}), null, 2),
'utf8'
)
}
// the BUILDING_DLL env var is set to avoid confusing the development environment
2017-05-17 12:01:52 +02:00
exec('./node_modules/strapi-helper-plugin/node_modules/cross-env/bin/cross-env.js BUILDING_DLL=true ./node_modules/strapi-helper-plugin/node_modules/webpack/bin/webpack.js --display-chunks --color --config ./node_modules/strapi-helper-plugin/lib/internals/webpack/webpack.dll.babel.js');