mirror of
https://github.com/PatrickJS/PatrickJS-starter.git
synced 2026-03-30 07:27:20 +00:00
* AoT and JIT builds complete successfully * Upgraded @ngtools/webpack to latest beta. * Fixed warnings, removed deprecated plugins, replaced npm run clean:dist and clean:aot with direct rimraf calls to speed up the script execution * Govinda Alwani : Upgraded HtmlElementsPlugin to support webpack 4. * Updateing angular 6 and ficing webpack issues and rxjs issue. * using RXJS lettable * Update README.md * Updating Angular latest and webpack latest * Updated lock file * Corrected package-lock.json * Got rid of outdated ngcWebpackPlugin. Instead using native AngularCompilerPlugin directly. * Added RxJs TSLint rules * Clean-up, refactoring, re-enabled disabled TSLint rules * Partially reverting previous change as it causes one of e2e tests to fail for no apparent reason... Have to be investigated.
82 lines
2.8 KiB
JavaScript
82 lines
2.8 KiB
JavaScript
/**
|
|
* @author: tipe.io
|
|
*/
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const helpers = require('./helpers');
|
|
const ghDeploy = require('./github-deploy');
|
|
const webpackMerge = require('webpack-merge'); // used to merge webpack configs
|
|
|
|
/**
|
|
* Webpack Constants
|
|
*/
|
|
const GIT_REMOTE_NAME = 'origin';
|
|
const COMMIT_MESSAGE = 'Updates';
|
|
const GH_REPO_NAME = ghDeploy.getRepoName(GIT_REMOTE_NAME);
|
|
|
|
module.exports = function(options) {
|
|
const webpackConfigFactory = ghDeploy.getWebpackConfigModule(options); // the settings that are common to prod and dev
|
|
const webpackConfig = webpackConfigFactory(options);
|
|
|
|
/**
|
|
* Replace the instance of HtmlWebpackPlugin with an updated one.
|
|
*/
|
|
ghDeploy.replaceHtmlWebpackPlugin(webpackConfig.plugins, GH_REPO_NAME);
|
|
|
|
return webpackMerge(webpackConfig, {
|
|
|
|
output: {
|
|
/**
|
|
* The public path is set to the REPO name.
|
|
*
|
|
* `HtmlElementsPlugin` will add it to all resources url's created by it.
|
|
* `HtmlWebpackPlugin` will add it to all webpack bundels/chunks.
|
|
*
|
|
* In theory publicPath shouldn't be used since the browser should automatically prefix the
|
|
* `baseUrl` into all URLs, however this is not the case when the URL is absolute (start with /)
|
|
*
|
|
* It's important to prefix & suffix the repo name with a slash (/).
|
|
* Prefixing so every resource will be absolute (otherwise it will be url.com/repoName/repoName...
|
|
* Suffixing since chunks will not do it automatically (testes against about page)
|
|
*/
|
|
publicPath: '/' + GH_REPO_NAME + '/' + ghDeploy.safeUrl(webpackConfig.output.publicPath)
|
|
},
|
|
|
|
plugins: [
|
|
function() {
|
|
this.plugin('done', function(stats) {
|
|
console.log('Starting deployment to GitHub.');
|
|
|
|
const logger = function(msg) {
|
|
console.log(msg);
|
|
};
|
|
|
|
const options = {
|
|
logger: logger,
|
|
remote: GIT_REMOTE_NAME,
|
|
message: COMMIT_MESSAGE,
|
|
dotfiles: true // for .nojekyll
|
|
};
|
|
/**
|
|
* Since GitHub moved to Jekyll 3.3, their server ignores the "node_modules" and "vendors" folder by default.
|
|
* but, as of now, it also ignores "vendors*" files.
|
|
* This means vendor.bundle.js or vendor.[chunk].bundle.js will return 404.
|
|
* this is the fix for now.
|
|
*/
|
|
fs.writeFileSync(path.join(webpackConfig.output.path, '.nojekyll'), '');
|
|
|
|
const ghpages = require('gh-pages');
|
|
ghpages.publish(webpackConfig.output.path, options, function(err) {
|
|
if (err) {
|
|
console.log('GitHub deployment done. STATUS: ERROR.');
|
|
throw err;
|
|
} else {
|
|
console.log('GitHub deployment done. STATUS: SUCCESS.');
|
|
}
|
|
});
|
|
});
|
|
}
|
|
]
|
|
});
|
|
};
|