简体   繁体   中英

Systemjs builder remove file extension

I have couple of es6 modules. add.js, sub.js and calc.js. calc.js imports add.js and sub.js.

I am building them with grunt and SystemJS builder. My grunt configuration for this looks like -

systemjs: {
  es6: {
     options: {
        baseURL: "/",
        configFile: "config.js",
     },
     files: [{
        "src": ["src/main/calc.js"],
        "dest": "dist/calc.js"
     }]
  }
}

Once the grunt build is done, it creates the resultant calc.js and in that file I can see this :

System.register("src/main/calc.js", [.. ..................

I don't want the .js in that name. I want it something like :

System.register("src/main/calc", [..

What should I do? Am I missing some configuration ?

This naming behavior is by design. bundle() creates a bundle for SystemJs to use in the browser, so the names must match the file names that SystemJs will be attempting to load. If you are trying to avoid SystemJs in the browser, buildStatic() is what you are looking for.

There is paths option for the builder.

paths: {
  "src/main/calc": "src/main/calc.js"
}

FYI, there is map option. I thought map would be the option for the purpose but it never worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM