session-desktop/Gruntfile.js
William Grant 5cf76c5f08 feat: build sass files using parcel instead of grunt
added sass watch command for auto building sass on file changes, cleaned up IE7 fallback css
2022-05-23 16:36:03 +10:00

50 lines
1.3 KiB
JavaScript

/* eslint-disable more/no-then, no-console */
module.exports = grunt => {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
exec: {
transpile: {
cmd: 'yarn transpile',
},
'build-protobuf': {
cmd: 'yarn build-protobuf',
},
},
gitinfo: {}, // to be populated by grunt gitinfo
});
Object.keys(grunt.config.get('pkg').devDependencies).forEach(key => {
if (/^grunt(?!(-cli)?$)/.test(key)) {
// ignore grunt and grunt-cli
grunt.loadNpmTasks(key);
}
});
function updateLocalConfig(update) {
const environment = process.env.SIGNAL_ENV || 'production';
const configPath = `config/local-${environment}.json`;
let localConfig;
try {
localConfig = grunt.file.readJSON(configPath);
} catch (e) {
//
}
localConfig = {
...localConfig,
...update,
};
grunt.file.write(configPath, `${JSON.stringify(localConfig)}\n`);
}
grunt.registerTask('getCommitHash', () => {
grunt.task.requires('gitinfo');
const gitinfo = grunt.config.get('gitinfo');
const hash = gitinfo.local.branch.current.SHA;
updateLocalConfig({ commitHash: hash });
});
grunt.registerTask('date', ['gitinfo']);
grunt.registerTask('default', ['exec:build-protobuf', 'exec:transpile', 'date', 'getCommitHash']);
};