mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
23 lines
557 B
JavaScript
23 lines
557 B
JavaScript
const path = require('node:path')
|
|
|
|
const loader = async function (content) {
|
|
this.async()
|
|
|
|
if (!this.resourcePath.endsWith('file-to-transform.ts')) {
|
|
return this.callback(null, content)
|
|
}
|
|
|
|
const dependencyFile = './file-dependency.ts'
|
|
const context = path.dirname(this.resourcePath)
|
|
const resolve = this.getResolve({})
|
|
const result = await resolve(context, dependencyFile)
|
|
this.addDependency(result)
|
|
|
|
this.callback(
|
|
null,
|
|
`export const utilFn = () => 'Generated at ${new Date().toISOString()}';`
|
|
)
|
|
}
|
|
|
|
module.exports = loader
|