Major refactoring using ESLint with rules from AirBnb and Vue. Enable most of the ESLint rules and do necessary linting in the code. Also add more information for rules that are disabled to describe what they are and why they are disabled. Allow logging (`console.log`) in test files, and in development mode (e.g. when working with `npm run serve`), but disable it when environment is production (as pre-configured by Vue). Also add flag (`--mode production`) in `lint:eslint` command so production linting is executed earlier in lifecycle. Disable rules that requires a separate work. Such as ESLint rules that are broken in TypeScript: no-useless-constructor (eslint/eslint#14118) and no-shadow (eslint/eslint#13014).
70 lines
2.5 KiB
JavaScript
70 lines
2.5 KiB
JavaScript
const { resolve } = require('path');
|
|
const { defineConfig } = require('@vue/cli-service');
|
|
const packageJson = require('./package.json');
|
|
|
|
loadVueAppRuntimeVariables();
|
|
|
|
module.exports = defineConfig({
|
|
chainWebpack: (config) => {
|
|
changeAppEntryPoint('./src/presentation/main.ts', config);
|
|
},
|
|
configureWebpack: {
|
|
resolve: {
|
|
alias: { // also requires path alias in tsconfig.json
|
|
'@tests': resolve(__dirname, 'tests/'),
|
|
},
|
|
fallback: {
|
|
/* Tell webpack to ignore polyfilling them because Node core modules are never used
|
|
for browser code but only for desktop where Electron supports them. */
|
|
...ignorePolyfills('os', 'child_process', 'fs', 'path'),
|
|
},
|
|
},
|
|
// Fix compilation failing on macOS when running unit/integration tests
|
|
externals: ['fsevents'],
|
|
},
|
|
pluginOptions: {
|
|
// https://nklayman.github.io/vue-cli-plugin-electron-builder/guide/guide.html#native-modules
|
|
electronBuilder: {
|
|
mainProcessFile: './src/presentation/electron/main.ts', // https://nklayman.github.io/vue-cli-plugin-electron-builder/guide/configuration.html#webpack-configuration
|
|
nodeIntegration: true, // required to reach Node.js APIs for environment specific logic
|
|
// https://www.electron.build/configuration/configuration
|
|
builderOptions: {
|
|
publish: [{
|
|
// https://www.electron.build/configuration/publish#githuboptions
|
|
// https://nklayman.github.io/vue-cli-plugin-electron-builder/guide/recipes.html#enable-publishing-to-github
|
|
provider: 'github',
|
|
vPrefixedTagName: false, // default: true
|
|
releaseType: 'release', // or "draft" (default), "prerelease"
|
|
}],
|
|
mac: { // https://www.electron.build/configuration/mac
|
|
target: 'dmg',
|
|
},
|
|
win: { // https://www.electron.build/configuration/win
|
|
target: 'nsis',
|
|
},
|
|
linux: { // https://www.electron.build/configuration/linux
|
|
target: 'AppImage',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
function changeAppEntryPoint(entryPath, config) {
|
|
config.entry('app').clear().add(entryPath).end();
|
|
}
|
|
|
|
function loadVueAppRuntimeVariables() {
|
|
process.env.VUE_APP_VERSION = packageJson.version;
|
|
process.env.VUE_APP_NAME = packageJson.name;
|
|
process.env.VUE_APP_REPOSITORY_URL = packageJson.repository.url;
|
|
process.env.VUE_APP_HOMEPAGE_URL = packageJson.homepage;
|
|
}
|
|
|
|
function ignorePolyfills(...moduleNames) {
|
|
return moduleNames.reduce((obj, module) => {
|
|
obj[module] = false;
|
|
return obj;
|
|
}, {});
|
|
}
|