4

I would like to have a different path for dev v production in JSPM.

I am using JSPM version 0.17, which creates a separate dev file. In my case they look something like this:

SystemJS.config({
    paths: {
        "npm:": "lib/npm/",
        "my_project/": "dist/"
    },
    browserConfig: {
        "baseURL": "/"
    },
    packages: {
        "my_project": {
            "main": "index.js"
        }
    }
});

SystemJS.config({
    packageConfigPaths: [
        "npm:@*/*.json",
        "npm:*.json"
    ],
    map: {
        "jquery": "npm:jquery@3.0.0"
    },
    packages: {}
});

and my config.dev.js filev looks something like this:

SystemJS.config({
    transpiler: "plugin-babel",
    packages: {
        "my_project": {
            "meta": {
                "*.js": {
                    "loader": "plugin-babel"
                }
            },
        }
    },
    map: {
        "plugin-babel": "npm:systemjs-plugin-babel@0.0.12"
    }
});

What I want to do is change the my_project path from dist/ to src/ when I include the config.dev.js file. The idea being that files within dist are all transpiled but src is my original files.

If I include config.dev.js then it should load files from src/ and fire the babel plugin. If I do not include config.dev.js then it should load from dist/ and not fire the transpiler.

I thought I could just add a new paths property to my dev config that would override the previously set item. This does not work, if I do the following in config.dev.js:

paths: {
    "my_projects/": "src/"
}

Instead of overriding my production value it just creates a loading error, 404 for mydomain/src (for some reason it tries to load the actual folder).

Stephen Simpson
  • 1,381
  • 1
  • 11
  • 23

0 Answers0