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

feat(index): add interpolation support (loaderUtils.interpolateName) #21

Merged
merged 3 commits into from
Feb 5, 2018

Conversation

Glinkis
Copy link
Contributor

@Glinkis Glinkis commented Jan 4, 2018

Since the other pull request by simonkorz has been idle for a long time, I thought I'd do it myself.
I have also made a small change in the readme to reflect the new syntax.

If a file is called file.js one could use 'exports-loader?[name]' to add 'module.exports = file;' to the file.

Example usage in config:

# webpack.conf.js
module: {
    rules: [
        {
            test: /\.js$/,
            use: [
                "imports-loader?THREE=three",
                "exports-loader?THREE.[name]"
            ],
            include: helpers.root("") + "/node_modules/three/examples/js"
        }
}

This allows to use all three examples as es6 or typescript modules.

import * as THREE from "three";
import "three/examples/js/loaders/ColladaLoader";
import "three/examples/js/controls/OrbitControls";

let loader = new THREE.ColladaLoader;
let orbit = new THREE.OrbitControls;

Example usage in config:

```js
# webpack.conf.js
module: {
    rules: [
        {
            test: /\.js$/,
            use: [
                "imports-loader?THREE=three",
                "exports-loader?THREE.[name]"
            ],
            include: helpers.root("") + "/node_modules/three/examples/js"
        }
}
```
This allows to use all three examples as es6 or typescript modules.

```js
import * as THREE from "three";
import "three/examples/js/loaders/ColladaLoader";
import "three/examples/js/controls/OrbitControls";

let loader = new THREE.ColladaLoader;
let orbit = new THREE.OrbitControls;
```
Removes extra copy/pasted characters.
Adds an example for the [name] syntax.
@michael-ciniawsky michael-ciniawsky changed the title Add support for filename [name] tags in module names. feat(index): add interpolation support for filenames (loaderUtils). Jan 8, 2018
@michael-ciniawsky michael-ciniawsky changed the title feat(index): add interpolation support for filenames (loaderUtils). feat(index): add interpolation support for filenames (loaderUtils) Jan 8, 2018
@Glinkis
Copy link
Contributor Author

Glinkis commented Jan 25, 2018

Any update on this? A new version with this functionality would improve my workflow quite a bit.

@michael-ciniawsky michael-ciniawsky changed the title feat(index): add interpolation support for filenames (loaderUtils) feat(index): add interpolation support (loaderUtils.interpolateName) Feb 5, 2018
@michael-ciniawsky michael-ciniawsky merged commit 201de63 into webpack-contrib:master Feb 5, 2018
@michael-ciniawsky
Copy link
Member

Released in v0.7.0 🎉 Thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants