Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support glob patterns in aurelia.build.resources #54

Closed
doktordirk opened this issue Jul 13, 2016 · 10 comments
Closed

Support glob patterns in aurelia.build.resources #54

doktordirk opened this issue Jul 13, 2016 · 10 comments

Comments

@doktordirk
Copy link

a) might help to announce those things
b) are wildcards supported?
eg to include all ValueConverters use
"aurelia-authentication/*ValueConverters"

@niieani
Copy link
Contributor

niieani commented Jul 13, 2016

Wildcards not supported. Interesting idea though, feel free to suggest a PR with implementation.
There'll be a blog announcement soon.

@niieani niieani changed the title aurelia.resources Support glob patterns in aurelia.build.resources Jul 13, 2016
@aaronroberson
Copy link

@niieani Can we do imports relative to the root directory (e.g. import {FooBar} from 'src/foo/bar';). The src directory does not appear to be implicit, and therefore import {Foo} from 'foo/bar' is not able to be resolved.

@aaronroberson
Copy link

aaronroberson commented Jul 18, 2016

Adding paths to resolve.root (see http://webpack.github.io/docs/configuration.html#resolve-root) does not work:

const baseConfig = {
  entry: {
    'app': ['./src/main'],
    'aurelia-bootstrap': ['./index'].concat(coreBundles.bootstrap),
    'aurelia': coreBundles.aurelia.filter(pkg => coreBundles.bootstrap.indexOf(pkg) === -1)
  },
  output: {
    path: outDir
  },
  ...
  resolve: {
    root: [
      path.resolve('./src'),
      path.resolve('./src/common'),
      path.resolve('./src/components'),
      path.resolve('./src/views')
    ]
  },
  ...
};

And:

config = generateConfig(
      baseConfig,

      require('@easy-webpack/config-env-development')(),

      require('@easy-webpack/config-aurelia')
      ({root: rootDir, src: srcDir, title: title, baseUrl: baseUrl}),

      require('@easy-webpack/config-babel')(),
      require('@easy-webpack/config-html')(),

      require('@easy-webpack/config-css')
      ({filename: 'styles.css', allChunks: !!ELECTRON, extractText: false, sourceMap: false}),

      require('@easy-webpack/config-fonts-and-images')(),
      require('@easy-webpack/config-global-bluebird')(),
      require('@easy-webpack/config-global-jquery')(),
      require('@easy-webpack/config-global-regenerator')(),
      require('@easy-webpack/config-generate-index-html')
      ({minify: false})
    );

@niieani
Copy link
Contributor

niieani commented Jul 18, 2016

@aaronroberson I honestly have no idea what you mean. This plugin has nothing to do with how you write ES6-style imports, it's only related to imports within templates and those done dynamically by aurelia-loader.

@aaronroberson
Copy link

I believe the @easy-webpack/config-aurelia package overwrites the resolve.root option. However, resolve.alias and resolve.fallback do not work either with @easy-webpack and therefore I'm forced to add the following to package.json to be maintained manually:

"aurelia": {
    "build": {
      "resources": [
        "common/models/base.model.js",
        "common/services/app-instance.service.js",
        "common/services/app.service.js",
        "common/services/nodes.service.js",
        "common/services/schema.service.js",
        "common/services/style-color.service.js",
        "common/services/test-data.js",
        "common/services/translated.service.js",
        "common/services/type.service.js",
        "common/utils/ashpod-fetch.js",
        "common/utils/auth-config.js",
        "common/utils/country-languages.js",
        "common/utils/drag-drop.js",
        "common/utils/group-by.js",
        "common/utils/json-translate-walker.js",
        "common/utils/json-walker.js",
        "common/utils/json.js",
        "common/utils/objectkeys.js",
        "common/utils/remove-inline-styles.js",
        "common/utils/select-format.js",
        "common/utils/test/api-mock.js",
        "common/utils/test/app-service-mock.js",
        "common/utils/test/binding-context-mock.js",
        "common/utils/test/drag-drop-mock.js",
        "common/utils/test/event-aggregator-mock.js",
        "common/utils/test/mocks.js",
        "common/utils/test/router-mock.js",
        "common/utils/test/setup.js",
        "common/utils/to-string.js",
        "components/add-item/add-item.js",
        "components/code-editor/code-editor.js",
        "components/collection-group/collection-group.js",
        "components/collections/collections.js",
        "components/column/column.js",
        "components/column-node/column-node.js",
        "components/content-library/content-library.js",
        "components/country-selector/country-selector.js",
        "components/cover-card/cover-card.js",
        "components/cs-carousel-form/cs-carousel-form.js",
        "components/cs-carousel-preview/cs-carousel-preview.js",
        "components/cs-image-form/cs-image-form.js",
        "components/cs-image-preview/cs-image-preview.js",
        "components/cs-structure-form/cs-structure-form.js",
        "components/cs-text-form/cs-text-form.js",
        "components/cs-text-preview/cs-text-preview.js",
        "components/cs-thread-form/cs-thread-form.js",
        "components/cs-thread-preview/cs-thread-preview.js",
        "components/cs-video-form/cs-video-form.js",
        "components/cs-video-preview/cs-video-preview.js",
        "components/cta/cta.js",
        "components/dropdown-select/dropdown-select.js",
        "components/library/library.js",
        "components/nav-bar/nav-bar.js",
        "components/property-editor/property-editor.js",
        "components/publish/publish.js",
        "components/related-thread/related-thread.js",
        "components/structure/structure.js",
        "components/theme-selector/theme-selector.js",
        "components/thread-nav-tabs/thread-nav-tabs.js",
        "components/thread-preview/thread-preview.js",
        "components/thread-target-toolbar/thread-target-toolbar.js",
        "components/thread-toolbar/thread-toolbar.js",
        "components/thread-translate-toolbar/thread-translate-toolbar.js",
        "components/tree-node/tree-node.js",
        "components/tree-select/tree-select.js",
        "components/wysiwyg/wysiwyg.js",
        "views/campaigns/campaigns.js",
        "views/collections/collections.js",
        "views/info/info.js",
        "views/publish/publish.js",
        "views/schema/schema.js",
        "views/thread-edit/sample-thread-data.js",
        "views/thread-edit/thread-edit.js",
        "views/thread-target/thread-target.js",
        "views/thread-translate/thread-translate.js",
        "fonts/glyphicons-halflings-regular.eot",
        "fonts/glyphicons-halflings-regular.svg",
        "fonts/glyphicons-halflings-regular.ttf",
        "fonts/glyphicons-halflings-regular.woff",
        "fonts/glyphicons-halflings-regular.woff2"
      ]
    }
  }
}

@niieani
Copy link
Contributor

niieani commented Jul 18, 2016

You don't need to put fonts into build resources.

config-aurelia doesn't override fallback, only root and modules. You can override these settings yourself anyway.
https://github.com/easy-webpack/config-aurelia/blob/master/src/index.ts

You need to put these files into build resources anyway, not sure how resolve.alias, nor resolve.fallback would help you.

A glob pattern will help you in the future.

@niieani
Copy link
Contributor

niieani commented Jul 26, 2016

Note to self: Would be nice to also generate globs from template strings, #56.

@Vheissu
Copy link
Member

Vheissu commented Jul 30, 2016

I am not promising anything. But once I get my other plugins converted over to my new structure, I might take a stab at implementing this into the Webpack plugin in the next few days. After all of the hard work @niieani has put into the Webpack integration, I'd love to be able to lift some of the burden.

Edit
I have started working on this. I think given the logic for parsing files for other files is there already, this won't be overly difficult. Ideally I would like to write tests for this and ensure it works before comfortably merging this in.

@niieani
Copy link
Contributor

niieani commented Jul 30, 2016

I looked into this before @Vheissu, but didn't get around to it. It should be a matter of:

  1. checking if the file (not dir) matching the literal expression exists

    a. if yes, continue
    b. if not, try parsing the glob via the glob package

  2. pass add all the resources from output to the next method

Really happy to hear you wanna help out with this 😄 👍

@niieani
Copy link
Contributor

niieani commented Apr 9, 2017

Fixed by the new AureliaPlugin (you can provide glob patterns, see wiki in the aurelia-webpack-plugin repo).

@niieani niieani closed this as completed Apr 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants