cannot import .task file
Answered
Africanized honey bee posted this in #help-forum
Africanized honey beeOP
Same error is this: https://stackoverflow.com/questions/76879349/cannot-import-task-file-in-next-js-typescript
But solution isn't working..
Anyone?
But solution isn't working..
Anyone?
18 Replies
@Africanized honey bee Same error is this: https://stackoverflow.com/questions/76879349/cannot-import-task-file-in-next-js-typescript
But solution isn't working..
Anyone?
i don't do ML, what is the format of this .task file and how do you use it in your code?
say if you could
import data from "./something.task" how do you use that data variable?the file is in a text file and you need the textual content?
Asian black bear
@Africanized honey bee It is because Next.js uses webpack v5 now, so file-loader isn't a thing. This should do the same thing (assuming you want to import the file contents as a string)
module.exports = {
module: {
rules: [
{
test: /\.task$/,
type: 'asset/source',
},
],
},
};And actually to add a custom webpack config you need to add a property to your next.config.js like this
webpack: (config, options) => {
config.module.rules.push( {
test: /\.task$/,
type: 'asset/source',
})
}@Asian black bear <@643178676862582814> It is because Next.js uses webpack v5 now, so file-loader isn't a thing. This should do the same thing (assuming you want to import the file contents as a string)
module.exports = {
module: {
rules: [
{
test: /\.task$/,
type: 'asset/source',
},
],
},
};
Africanized honey beeOP
Cool thanks
Quick question, i uploaded it on public and used
conts filename="/{filename}"
Any downside of this?
@Asian black bear
conts filename="/{filename}"
Any downside of this?
@Asian black bear
@Africanized honey bee Quick question, i uploaded it on public and used
conts filename="/{filename}"
Any downside of this?
<@611000252438413342>
Asian black bear
the file would only be available on the client
@Asian black bear the file would only be available on the client
Africanized honey beeOP
So this is google file for hand detection. It won't be a problem. And it's working as I expected
Asian black bear
right on
are you
fetching it on the client?@Asian black bear are you `fetch`ing it on the client?
Africanized honey beeOP
Yeap
Asian black bear
oh yeah,
/public is a just fine way to do it thenAnswer
Asian black bear
If you wanted it to get the Webpack immutable filename and cache/cache-busting benefits you could use the
'asset/inline' insteadthen the import would return a path string that you could obtain the file on the client with
fetchAfricanized honey beeOP
Cool, thanks for info 🙂
Asian black bear
yep! hope your project works well