forked from ppfun/pixelplanet
clean webpack cache on full build
add option to clena assets
This commit is contained in:
parent
997d887cfd
commit
872c3a5659
|
@ -3,6 +3,8 @@
|
|||
* Lets split that here
|
||||
*/
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const webpack = require('webpack');
|
||||
const serverConfig = require('../webpack.config.server.js');
|
||||
const clientConfig = require('../webpack.config.client.js');
|
||||
|
@ -22,6 +24,9 @@ function compile(webpackConfig) {
|
|||
}
|
||||
|
||||
async function buildProduction() {
|
||||
// cleanup old files
|
||||
fs.rmSync(path.resolve(__dirname, '..', 'node_modules', '.cache', 'webpack'), { recursive: true, force: true });
|
||||
// fs.rmSync(path.resolve(__dirname, '..', 'dist', 'public', 'assets'), { recursive: true, force: true });
|
||||
// server files
|
||||
console.log('-----------------------------');
|
||||
console.log(`Build server...`);
|
||||
|
@ -43,6 +48,7 @@ async function buildProduction() {
|
|||
analyze: false,
|
||||
extract: false,
|
||||
locale: lang,
|
||||
clean: (i === 0),
|
||||
}));
|
||||
}
|
||||
console.log(`Finished building in ${(Date.now() - st) / 1000}s`);
|
||||
|
|
|
@ -18,6 +18,7 @@ function buildWebpackClientConfig(
|
|||
analyze,
|
||||
locale,
|
||||
extract,
|
||||
clean,
|
||||
) {
|
||||
const ttag = {
|
||||
resolve: {
|
||||
|
@ -61,7 +62,7 @@ function buildWebpackClientConfig(
|
|||
? '[name].[chunkhash:8].js'
|
||||
: `[name].${locale}.[chunkhash:8].js`,
|
||||
chunkFilename: `[name].${locale}.[chunkhash:8].js`,
|
||||
clean: true,
|
||||
clean,
|
||||
},
|
||||
|
||||
resolve: {
|
||||
|
@ -174,8 +175,7 @@ function buildWebpackClientConfig(
|
|||
chunkModules: false,
|
||||
},
|
||||
|
||||
cache: (extract) ? false
|
||||
: {
|
||||
cache: {
|
||||
type: 'filesystem',
|
||||
},
|
||||
};
|
||||
|
@ -217,11 +217,11 @@ function buildWebpackClientConfigAllLangs() {
|
|||
* @return webpack configuration
|
||||
*/
|
||||
module.exports = ({
|
||||
development, analyze, extract, locale,
|
||||
development, analyze, extract, locale, clean,
|
||||
}) => {
|
||||
if (extract || analyze || locale || development) {
|
||||
if (extract || analyze || locale || development || clean) {
|
||||
return buildWebpackClientConfig(
|
||||
development, analyze, locale || 'en', extract,
|
||||
development, analyze, locale || 'en', extract, clean,
|
||||
);
|
||||
}
|
||||
return buildWebpackClientConfigAllLangs(development);
|
||||
|
|
Loading…
Reference in New Issue
Block a user