diff options
author | Kristóf Marussy <kristof@marussy.com> | 2022-08-12 19:54:46 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2022-08-12 19:54:46 +0200 |
commit | d22c3b0c257f5daf5b401988a35ab9ce981a2341 (patch) | |
tree | 0a661c927c37b52197326d1c05e211daf9bd19e5 /subprojects/frontend/build.gradle | |
parent | fix(language): rule parsing test (diff) | |
download | refinery-d22c3b0c257f5daf5b401988a35ab9ce981a2341.tar.gz refinery-d22c3b0c257f5daf5b401988a35ab9ce981a2341.tar.zst refinery-d22c3b0c257f5daf5b401988a35ab9ce981a2341.zip |
refactor(frontend): move from Webpack to Vite
Also overhaulds the building and linting for frontend assets.
Diffstat (limited to 'subprojects/frontend/build.gradle')
-rw-r--r-- | subprojects/frontend/build.gradle | 73 |
1 files changed, 34 insertions, 39 deletions
diff --git a/subprojects/frontend/build.gradle b/subprojects/frontend/build.gradle index 71444e89..5ed90c31 100644 --- a/subprojects/frontend/build.gradle +++ b/subprojects/frontend/build.gradle | |||
@@ -5,11 +5,11 @@ plugins { | |||
5 | 5 | ||
6 | import org.siouan.frontendgradleplugin.infrastructure.gradle.RunYarn | 6 | import org.siouan.frontendgradleplugin.infrastructure.gradle.RunYarn |
7 | 7 | ||
8 | def webpackOutputDir = "${buildDir}/webpack" | 8 | def viteOutputDir = "${buildDir}/vite" |
9 | def productionResources = file("${webpackOutputDir}/production") | 9 | def productionResources = file("${viteOutputDir}/production") |
10 | 10 | ||
11 | frontend { | 11 | frontend { |
12 | assembleScript = 'assemble:webpack' | 12 | assembleScript = 'run build' |
13 | } | 13 | } |
14 | 14 | ||
15 | configurations { | 15 | configurations { |
@@ -21,23 +21,10 @@ configurations { | |||
21 | 21 | ||
22 | def installFrontend = tasks.named('installFrontend') | 22 | def installFrontend = tasks.named('installFrontend') |
23 | 23 | ||
24 | def generateLezerGrammar = tasks.register('generateLezerGrammar', RunYarn) { | ||
25 | dependsOn installFrontend | ||
26 | inputs.file 'src/language/problem.grammar' | ||
27 | inputs.file 'package.json' | ||
28 | inputs.file rootProject.file('yarn.lock') | ||
29 | outputs.file "${buildDir}/generated/sources/lezer/problem.ts" | ||
30 | outputs.file "${buildDir}/generated/sources/lezer/problem.terms.ts" | ||
31 | script = 'run assemble:lezer' | ||
32 | } | ||
33 | |||
34 | def assembleFrontend = tasks.named('assembleFrontend') | 24 | def assembleFrontend = tasks.named('assembleFrontend') |
35 | assembleFrontend.configure { | 25 | assembleFrontend.configure { |
36 | dependsOn generateLezerGrammar | ||
37 | inputs.dir 'src' | 26 | inputs.dir 'src' |
38 | inputs.file "${buildDir}/generated/sources/lezer/problem.ts" | 27 | inputs.files('package.json', 'tsconfig.json', 'tsconfig.base.json', 'vite.config.ts') |
39 | inputs.file "${buildDir}/generated/sources/lezer/problem.terms.ts" | ||
40 | inputs.files('package.json', 'webpack.config.js') | ||
41 | inputs.file rootProject.file('yarn.lock') | 28 | inputs.file rootProject.file('yarn.lock') |
42 | outputs.dir productionResources | 29 | outputs.dir productionResources |
43 | } | 30 | } |
@@ -48,54 +35,62 @@ artifacts { | |||
48 | } | 35 | } |
49 | } | 36 | } |
50 | 37 | ||
51 | def eslint = tasks.register('eslint', RunYarn) { | 38 | def typecheckFrontend = tasks.register('typecheckFrontend', RunYarn) { |
52 | dependsOn installFrontend | 39 | dependsOn installFrontend |
53 | inputs.dir 'src' | 40 | inputs.dir 'src' |
54 | inputs.files('.eslintrc.js', 'tsconfig.json') | 41 | inputs.files('package.json', 'tsconfig.json', 'tsconfig.base.json', 'tsconfig.node.json') |
42 | inputs.file rootProject.file('yarn.lock') | ||
43 | outputs.dir "${buildDir}/typescript" | ||
44 | script = 'run typecheck' | ||
45 | group = 'verification' | ||
46 | description = 'Check for TypeScript type errors.' | ||
47 | } | ||
48 | |||
49 | def lintFrontend = tasks.register('lintFrontend', RunYarn) { | ||
50 | dependsOn installFrontend | ||
51 | inputs.dir 'src' | ||
52 | inputs.files('.eslintrc.cjs', 'prettier.config.cjs') | ||
53 | inputs.files('package.json', 'tsconfig.json', 'tsconfig.base.json', 'tsconfig.node.json') | ||
55 | inputs.file rootProject.file('yarn.lock') | 54 | inputs.file rootProject.file('yarn.lock') |
56 | if (project.hasProperty('ci')) { | 55 | if (project.hasProperty('ci')) { |
57 | outputs.file "${buildDir}/eslint.json" | 56 | outputs.file "${buildDir}/eslint.json" |
58 | script = 'run check:eslint:ci' | 57 | script = 'run lint:ci' |
59 | } else { | 58 | } else { |
60 | script = 'run check:eslint' | 59 | script = 'run lint' |
61 | } | 60 | } |
62 | group = 'verification' | 61 | group = 'verification' |
63 | description = 'Check for TypeScript errors.' | 62 | description = 'Check for TypeScript lint errors and warnings.' |
64 | } | 63 | } |
65 | 64 | ||
66 | def stylelint = tasks.register('stylelint', RunYarn) { | 65 | def prettier = tasks.register('fixFrontend', RunYarn) { |
67 | dependsOn installFrontend | 66 | dependsOn installFrontend |
68 | inputs.dir 'src' | 67 | inputs.dir 'src' |
69 | inputs.file '.stylelintrc.js' | 68 | inputs.files('.eslintrc.cjs', 'prettier.config.cjs') |
69 | inputs.files('package.json', 'tsconfig.json', 'tsconfig.base.json', 'tsconfig.node.json') | ||
70 | inputs.file rootProject.file('yarn.lock') | 70 | inputs.file rootProject.file('yarn.lock') |
71 | if (project.hasProperty('ci')) { | 71 | script = 'run lint:fix' |
72 | outputs.file "${buildDir}/stylelint.json" | ||
73 | script = 'run check:stylelint:ci' | ||
74 | } else { | ||
75 | script = 'run check:stylelint' | ||
76 | } | ||
77 | group = 'verification' | 72 | group = 'verification' |
78 | description = 'Check for Sass errors.' | 73 | description = 'Fix TypeScript lint errors and warnings.' |
79 | } | 74 | } |
80 | 75 | ||
81 | tasks.named('check') { | 76 | tasks.named('check') { |
82 | dependsOn(eslint, stylelint) | 77 | dependsOn(typecheckFrontend) |
78 | dependsOn(lintFrontend) | ||
83 | } | 79 | } |
84 | 80 | ||
85 | tasks.register('webpackServe', RunYarn) { | 81 | tasks.register('serveFrontend', RunYarn) { |
86 | dependsOn installFrontend | 82 | dependsOn installFrontend |
87 | dependsOn generateLezerGrammar | 83 | inputs.dir 'src' |
88 | outputs.dir "${webpackOutputDir}/development" | 84 | inputs.files('package.json', 'tsconfig.json', 'tsconfig.base.json', 'vite.config.ts') |
85 | inputs.file rootProject.file('yarn.lock') | ||
86 | outputs.dir "${viteOutputDir}/development" | ||
89 | script = 'run serve' | 87 | script = 'run serve' |
90 | group = 'run' | 88 | group = 'run' |
91 | description = 'Start a Webpack dev server with hot module replacement.' | 89 | description = 'Start a Vite dev server with hot module replacement.' |
92 | } | 90 | } |
93 | 91 | ||
94 | sonarqube.properties { | 92 | sonarqube.properties { |
95 | properties['sonar.sources'] += ['src'] | 93 | properties['sonar.sources'] += ['src'] |
96 | property 'sonar.nodejs.executable', "${frontend.nodeInstallDirectory.get()}/bin/node" | 94 | property 'sonar.nodejs.executable', "${frontend.nodeInstallDirectory.get()}/bin/node" |
97 | property 'sonar.eslint.reportPaths', "${buildDir}/eslint.json" | 95 | property 'sonar.eslint.reportPaths', "${buildDir}/eslint.json" |
98 | property 'sonar.css.stylelint.reportPaths', "${buildDir}/stylelint.json" | ||
99 | // SonarJS does not pick up typescript files with `exactOptionalPropertyTypes` | ||
100 | property 'sonar.typescript.tsconfigPath', 'tsconfig.sonar.json' | ||
101 | } | 96 | } |