-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
128 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
import { DepOptimizationConfig } from 'vite'; | ||
import { esBuildResolver } from './esbuild-resolver'; | ||
|
||
export interface OptimizeDeps { | ||
exclude?: string[]; | ||
[key: string]: unknown; | ||
} | ||
|
||
export function optimizeDeps(): OptimizeDeps { | ||
export function optimizeDeps({ appExtensions }: DepOptimizationConfig & { appExtensions: string[] }): OptimizeDeps { | ||
return { | ||
exclude: ['@embroider/macros'], | ||
extensions: ['.hbs', '.gjs', '.gts'], | ||
esbuildOptions: { | ||
plugins: [esBuildResolver()], | ||
plugins: [esBuildResolver(appExtensions)], | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,59 @@ | ||
import { defineConfig } from 'vite'; | ||
import { resolver, hbs, scripts, templateTag, optimizeDeps, compatPrebuild, contentFor } from '@embroider/vite'; | ||
import { resolver, hbs, scripts, templateTag, optimizeDeps, compatPrebuild, assets, contentFor } from '@embroider/vite'; | ||
import { resolve } from 'path'; | ||
import { babel } from '@rollup/plugin-babel'; | ||
|
||
const root = 'tmp/rewritten-app'; | ||
const extensions = ['.mjs', '.gjs', '.js', '.mts', '.gts', '.ts', '.hbs', '.json']; | ||
|
||
export default defineConfig({ | ||
root, | ||
// esbuild in vite does not support decorators | ||
esbuild: false, | ||
cacheDir: resolve('node_modules', '.vite'), | ||
resolve: { | ||
extensions: ['.mjs', '.gjs', '.js', '.mts', '.gts', '.ts', '.hbs', '.json'], | ||
}, | ||
|
||
plugins: [ | ||
hbs(), | ||
templateTag(), | ||
scripts(), | ||
resolver(), | ||
compatPrebuild(), | ||
contentFor(), | ||
export default defineConfig(({ mode }) => { | ||
return { | ||
root, | ||
cacheDir: resolve('node_modules', '.vite'), | ||
resolve: { | ||
extensions, | ||
}, | ||
plugins: [ | ||
hbs(), | ||
templateTag(), | ||
scripts(), | ||
resolver(), | ||
compatPrebuild(), | ||
assets(), | ||
contentFor(), | ||
|
||
babel({ | ||
babelHelpers: 'runtime', | ||
babel({ | ||
babelHelpers: 'runtime', | ||
|
||
// this needs .hbs because our hbs() plugin above converts them to | ||
// javascript but the javascript still also needs babel, but we don't want | ||
// to rename them because vite isn't great about knowing how to hot-reload | ||
// them if we resolve them to made-up names. | ||
extensions: ['.gjs', '.js', '.hbs', '.ts', '.gts'], | ||
// this needs .hbs because our hbs() plugin above converts them to | ||
// javascript but the javascript still also needs babel, but we don't want | ||
// to rename them because vite isn't great about knowing how to hot-reload | ||
// them if we resolve them to made-up names. | ||
extensions, | ||
}), | ||
], | ||
optimizeDeps: optimizeDeps({ | ||
appExtensions: extensions, | ||
}), | ||
], | ||
optimizeDeps: optimizeDeps(), | ||
server: { | ||
port: 4200, | ||
watch: { | ||
ignored: ['!**/tmp/rewritten-app/**'], | ||
publicDir: resolve(process.cwd(), 'public'), | ||
server: { | ||
port: 4200, | ||
watch: { | ||
ignored: ['!**/tmp/**'], | ||
}, | ||
}, | ||
}, | ||
build: { | ||
outDir: resolve(process.cwd(), 'dist'), | ||
rollupOptions: { | ||
input: { | ||
main: resolve(root, 'index.html'), | ||
tests: resolve(root, 'tests/index.html'), | ||
build: { | ||
outDir: resolve(process.cwd(), 'dist'), | ||
rollupOptions: { | ||
input: { | ||
main: resolve(root, 'index.html'), | ||
...(shouldBuildTests(mode) ? { tests: resolve(root, 'tests/index.html') } : undefined), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
}); | ||
|
||
function shouldBuildTests(mode) { | ||
return mode !== 'production' || process.env.FORCE_BUILD_TESTS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,59 @@ | ||
import { defineConfig } from 'vite'; | ||
import { resolver, hbs, scripts, templateTag, optimizeDeps, compatPrebuild, contentFor } from '@embroider/vite'; | ||
import { resolver, hbs, scripts, templateTag, optimizeDeps, compatPrebuild, assets, contentFor } from '@embroider/vite'; | ||
import { resolve } from 'path'; | ||
import { babel } from '@rollup/plugin-babel'; | ||
|
||
const root = 'tmp/rewritten-app'; | ||
const extensions = ['.mjs', '.gjs', '.js', '.mts', '.gts', '.ts', '.hbs', '.json']; | ||
|
||
export default defineConfig({ | ||
root, | ||
// esbuild in vite does not support decorators | ||
esbuild: false, | ||
cacheDir: resolve('node_modules', '.vite'), | ||
resolve: { | ||
extensions: ['.mjs', '.gjs', '.js', '.mts', '.gts', '.ts', '.hbs', '.json'], | ||
}, | ||
|
||
plugins: [ | ||
hbs(), | ||
templateTag(), | ||
scripts(), | ||
resolver(), | ||
compatPrebuild(), | ||
contentFor(), | ||
export default defineConfig(({ mode }) => { | ||
return { | ||
root, | ||
cacheDir: resolve('node_modules', '.vite'), | ||
resolve: { | ||
extensions, | ||
}, | ||
plugins: [ | ||
hbs(), | ||
templateTag(), | ||
scripts(), | ||
resolver(), | ||
compatPrebuild(), | ||
assets(), | ||
contentFor(), | ||
|
||
babel({ | ||
babelHelpers: 'runtime', | ||
babel({ | ||
babelHelpers: 'runtime', | ||
|
||
// this needs .hbs because our hbs() plugin above converts them to | ||
// javascript but the javascript still also needs babel, but we don't want | ||
// to rename them because vite isn't great about knowing how to hot-reload | ||
// them if we resolve them to made-up names. | ||
extensions: ['.gjs', '.js', '.hbs', '.ts', '.gts'], | ||
// this needs .hbs because our hbs() plugin above converts them to | ||
// javascript but the javascript still also needs babel, but we don't want | ||
// to rename them because vite isn't great about knowing how to hot-reload | ||
// them if we resolve them to made-up names. | ||
extensions, | ||
}), | ||
], | ||
optimizeDeps: optimizeDeps({ | ||
appExtensions: extensions, | ||
}), | ||
], | ||
optimizeDeps: optimizeDeps(), | ||
server: { | ||
port: 4200, | ||
watch: { | ||
ignored: ['!**/tmp/rewritten-app/**'], | ||
publicDir: resolve(process.cwd(), 'public'), | ||
server: { | ||
port: 4200, | ||
watch: { | ||
ignored: ['!**/tmp/**'], | ||
}, | ||
}, | ||
}, | ||
build: { | ||
outDir: resolve(process.cwd(), 'dist'), | ||
rollupOptions: { | ||
input: { | ||
main: resolve(root, 'index.html'), | ||
tests: resolve(root, 'tests/index.html'), | ||
build: { | ||
outDir: resolve(process.cwd(), 'dist'), | ||
rollupOptions: { | ||
input: { | ||
main: resolve(root, 'index.html'), | ||
...(shouldBuildTests(mode) ? { tests: resolve(root, 'tests/index.html') } : undefined), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
}); | ||
|
||
function shouldBuildTests(mode) { | ||
return mode !== 'production' || process.env.FORCE_BUILD_TESTS; | ||
} |