Skip to content

Instantly share code, notes, and snippets.

@Nedlinin
Created April 29, 2016 14:51
Show Gist options
  • Save Nedlinin/75ace532e6008704d8ce11f2a9a9f7d4 to your computer and use it in GitHub Desktop.
Save Nedlinin/75ace532e6008704d8ce11f2a9a9f7d4 to your computer and use it in GitHub Desktop.
//Gulpfile.js
const gulp = require("gulp");
const rollup = require("rollup");
const sourcemaps = require('gulp-sourcemaps');
const nodeResolve = require('rollup-plugin-node-resolve');
const commonjs = require("rollup-plugin-commonjs");
const babel = require('rollup-plugin-babel');
const replace = require('rollup-plugin-replace');
gulp.task("scripts", function () {
return rollup.rollup({
entry: "./src/js/main.js",
plugins: [
replace({
"process.env.NODE_ENV": '"development"'
}),
nodeResolve({
main: true,
skip: [ "esri" ] // Let Dojo handle Esri
}),
commonjs({
// non-CommonJS modules will be ignored, but you can also
// specifically include/exclude files
include: "node_modules/**"
}),
babel({
exclude: "node_modules/**"
})
]
}).then(function(bundle) {
bundle.write({
format: "amd", // AMD is Dojo compatible
dest: "build/js/main.js",
sourceMap: true
});
})
});
@Nedlinin
Copy link
Author

Also made mods to index.html to support rollup

    <script>
        var base = location.href.replace(/\/[^/]+$/, "").slice(0, -1);
        var dojoConfig = {
            parseOnLoad: false,
            async: true,
            cacheBust: "0.0.1",
            packages: [
                { name: "js", location: base + "/js" }
            ],
            deps: ["dojo/domReady!"],
            callback: function () {
                require(["js/main"]);
            }
        };
    </script>

    <!-- ArcGIS api -->
    <script src="https://js.arcgis.com/4.0beta3/" async></script>

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