GithubHelp home page GithubHelp logo

Comments (4)

webdiscus avatar webdiscus commented on June 16, 2024 2

@m10

In v2.6.4 is enabled supports for resolve.modules options defined in webpack config.

P.S. all performance optimised pre-settings of Webpack resolver was removed. Now you can change every options of Webpack resolver.

from pug-loader.

webdiscus avatar webdiscus commented on June 16, 2024

@m10

you can use Webpack aliases, e.g.:

  resolve: {
    alias: {
      Views: path.join(__dirname, 'src/views/'),
      Images: path.join(__dirname, 'src/assets/images/'),
      Fonts: path.join(__dirname, 'src/assets/fonts/'),
      Styles: path.join(__dirname, 'src/assets/styles/'),
      Scripts: path.join(__dirname, 'src/assets/scripts/'),
    },
  },

Usage of aliases in Pug

extends Views/layouts/default
include Views/mixins
img(src=require('Images/image.jpg'))
- const data = require('Scripts/data.json')

Usage of aliases in SCSS

@font-face {
  font-family: 'OpenSans';
  src:
    url('Fonts/OpenSans/open-sans-regular.svg') format('svg'),
    url('Fonts/OpenSans/open-sans-regular.woff2') format('woff2');
  font-style: normal;
}

.header {
  background-image: url('Images/image.jpg');
}

P.S. I'm not sure if supporting resolve.modules is important. I have set this enhancement to a low priority and do it in my free time.

from pug-loader.

m10 avatar m10 commented on June 16, 2024

thanks for taking the time to look into it. I appreciate your effort!

I know that one can use aliases too but when adding/removing folders one would have to add/remove aliases too..
It is more dynamic and intuitive with modules.

Just IMHO: Dependency resolution should work consistently across Webpack. It's what users expect. Any difference should at least be documented.

We have legacy projects where this is used. Migrating them to this loader would be more difficult without this support.
On new projects it would be possible to work around this, even though it would be nice to keep the workflow

from pug-loader.

webdiscus avatar webdiscus commented on June 16, 2024

@m10

from readme > features:

...

...
and here are many examples of resolving
Currently is supported what is documented ;-)

Many of my and many client projects have never never used the resolve.module.
If support is required now, then well, I will do it.

from pug-loader.

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.