Giter Site home page Giter Site logo

Comments (4)

hyanwong avatar hyanwong commented on June 12, 2024 1

supporting all placeholders by TemplatePathPlugin is not a realistic approach in my opinion.

I agree! (there are some other libraries that will do the templating for you, e.g. https://github.com/webpack/webpack/blob/master/lib/TemplatedPathPlugin.js) but you probably don't want to reply on other libs)

So we need to think about some workaround or another way.
I guess your expectation will be fulfilled by providing another placeholder for "Output filename" right?

Well, possibly, although I actually am producing 2 output files, and I want to cut the hash out of both, so it might be a bit more complicated. I actually have solved my problem by, instead of using a symlink, using the FileManagerPlugin plugin which can do a copy with [hash] templated filenames, so there's no urgency for me to get this into SymlinkWebpackPlugin, but it would be preferable.

Thanks!

from symlink-webpack-plugin.

hyanwong avatar hyanwong commented on June 12, 2024

It seems like you can access the hash using the webpack.ExtendedAPIPlugin, which creates a global variable __webpack_hash__, but I can't get this to work as I expect. E.g. I was hoping to do something like this:

  plugins: [
    new webpack.ExtendedAPIPlugin(),
    new SymlinkWebpackPlugin({ origin: 'entry.' + __webpack_hash__ + '.js', symlink: 'entry.js' }),

But I get >> ReferenceError: _webpack_hash_ is not defined. It there any easy way to access this from within the SymlinkWebpackPlugin config object?

from symlink-webpack-plugin.

hmsk avatar hmsk commented on June 12, 2024

Thanks for your effort to find out the way to make that happens :)
[name], [hash] are actually resolved by TemplatePathPlugin on compilation, assetPath hook.

But SymlinkWebpackPlugin works among the emitted outputs where all pathnames are resolved. And supporting all placeholders by TemplatePathPlugin is not a realistic approach in my opinion.

So we need to think about some workaround or another way.
I guess your expectation will be fulfilled by providing another placeholder for "Output filename" right?

I'm wondering if we can write the config as:

{ origin: '[output]', symlink: 'entry.js' }

Probably this makes that [name].[hash].js is linked from entry.js.

Does this work for you? If so, I may work on supporting that πŸ€”

from symlink-webpack-plugin.

hmsk avatar hmsk commented on June 12, 2024

Good point. Need more considerations to support multiple outputs πŸ€”
FileManagerPlugin seems to provide appropriate features with RegexGlob and [hash]. Let me look into this weekend. Thanks for your input!

from symlink-webpack-plugin.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.