dc7290 / template-ejs-loader

ejs-loader with webpack5 support. Chain it to html-loader and use it with html-webpack-plugin.
MIT License
24 stars 3 forks source link

Try to fix the passing variable problem #17

Closed mizok closed 2 years ago

mizok commented 2 years ago

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

@dc7290

I tried the solution I mentioned in #16 (using customized includer function). And things seem to work without problem(I am not very sure if this will cause any side effect or problem, 'cause I still don't have time for a full-test.)

but THIS did work: img result: img

And bc it is gonna be a big change(if you think this solution is ok), I guess it should be checked carefully.

fix #16

Type of change

Please delete options that are not relevant.

Bug fix I guess.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

I forked this repo, change index.ts then run build, then copy paste all the built library to the node_modules in my testing repo.

Checklist:

dc7290 commented 2 years ago

@mizok Did I understand #16 correctly that you can include ejs files, but they are not recognized as webpack dependencies? If so, does this solution update the webpack dependencies?

mizok commented 2 years ago

@dc7290 I guess you missed this?

devServer: {

watchFiles: ['*.html', 'src/template/*.html', '*.ejs', 'src/template/*.ejs','src/template/**/*.ejs'],  // this is important

},

You will have to watch all your file if that is gonna be dependency

mizok commented 2 years ago

@mizok Did I understand #16 correctly that you can include ejs files, but they are not recognized as webpack dependencies? If so, does this solution update the webpack dependencies?

@dc7290

Yes, you understood correctly.

And about your second question, you can check my change , I thought I did add

this.addDependency(parsedPath);

I guess it's line 93 or some what :/

mizok commented 2 years ago

@mizok

If so, does this solution update the webpack dependencies?

Yap ,it does.

dc7290 commented 2 years ago

@mizok I'm impressed! The idea of using customIncluder as a way to add dependencies to webpack was an eye opener.

As for the code formatting, I would like to see a slight modification, so please just do that.

dc7290 commented 2 years ago

@mizok Try running the following command again.

yarn

Then husky will be installed and will automatically lint and format the file before committing it.

mizok commented 2 years ago

@mizok Try running the following command again.

yarn

Then husky will be installed and will automatically lint and format the file before committing it.

ok sure :D

mizok commented 2 years ago

@dc7290

OK, I guess the lint things are done already, just check it.

dc7290 commented 2 years ago

@mizok Nice!