Giter Club home page Giter Club logo

Comments (3)

tongueroo avatar tongueroo commented on July 21, 2024

Thinking you have to add import statements. This might help https://github.com/tongueroo/jets-example-crud-html/blob/master/app/javascript/packs/application.js

from jets.

zeetao avatar zeetao commented on July 21, 2024

Hmm... am not sure what you mean. I tried adding more directories to the webpacker.yml file for it to compile but it didnt work.
The reference at http://rubyonjets.com/docs/assets-serving/ states that I should put images into the app/javascript/images folder, but this does not work.
If I put all images into app/javascript/packs, then it does get compiled, but then it converts all my images into .js extensions.....

These paths in webpacker.yml:
source_path: app/javascript
source_entry_path: packs
public_output_path: packs
cache_path: tmp/cache/webpacker

I tried the below and it still didn't work
source_entry_path: [packs, images]
source_entry_path: ['packs', 'images']
source_entry_path: %w[packs images]

I tried importing as you suggested but it looks odd and also didn't work.
import '../images/'

What am I doing wrong?

from jets.

tongueroo avatar tongueroo commented on July 21, 2024

Made some webpacker fixes in the latest release, so first upgrade. Then to import images you actually have to import them explicitly. So this that code won't work 😞

import '../images/'

Something like this will work:

import '../images/path/to/full/image.png'

It’s not great to have to import a large number of image explicitly though. Googled around and it looks like what folks are doing with webpacker is using ERB to loop and import a bunch of files dynamically. Started taking a look at getting webpacker with ERB working but afraid don’t have the time right now. Would be awesome if someone takes a stab at this and would happily take this PR. IMHO, it’s a great way to learn if you want to have a stab at it also. No sweat either way though πŸ‘Œ

Closing this out.

from jets.

Related Issues (20)

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.