2018-09-28 13:43:58 +03:00
|
|
|
import nodeResolve from "rollup-plugin-node-resolve";
|
|
|
|
import { uglify } from "rollup-plugin-uglify";
|
|
|
|
import replace from "rollup-plugin-replace";
|
|
|
|
import commonjs from "rollup-plugin-commonjs";
|
|
|
|
import shim from "rollup-plugin-shim";
|
2018-09-26 06:08:03 +03:00
|
|
|
|
2018-09-28 13:43:58 +03:00
|
|
|
const version = require("./package.json").version;
|
|
|
|
const banner = [
|
|
|
|
"/*!",
|
|
|
|
` * Azure Storage SDK for JavaScript - Blob, ${version}`,
|
|
|
|
" * Copyright (c) Microsoft and contributors. All rights reserved.",
|
|
|
|
" */"
|
|
|
|
].join("\n");
|
|
|
|
|
|
|
|
const nodeRollupConfigFactory = () => {
|
|
|
|
return {
|
|
|
|
external: ["ms-rest-js", "crypto", "fs", "events", "os"],
|
|
|
|
input: "dist-esm/lib/index.js",
|
2018-09-26 06:08:03 +03:00
|
|
|
output: {
|
2018-09-28 13:43:58 +03:00
|
|
|
file: "dist/index.js",
|
|
|
|
format: "cjs",
|
2018-09-26 06:08:03 +03:00
|
|
|
sourcemap: true
|
|
|
|
},
|
2018-09-28 13:43:58 +03:00
|
|
|
plugins: [nodeResolve(), uglify()]
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const browserRollupConfigFactory = isProduction => {
|
|
|
|
const browserRollupConfig = {
|
|
|
|
input: "dist-esm/lib/index.browser.js",
|
2018-09-26 06:08:03 +03:00
|
|
|
output: {
|
2018-09-28 13:43:58 +03:00
|
|
|
file: "browser/azure-storage.blob.js",
|
|
|
|
banner: banner,
|
|
|
|
format: "umd",
|
|
|
|
name: "azblob",
|
2018-09-26 06:08:03 +03:00
|
|
|
sourcemap: true
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
replace({
|
2018-09-28 13:43:58 +03:00
|
|
|
delimiters: ["", ""],
|
2018-09-26 06:08:03 +03:00
|
|
|
values: {
|
|
|
|
// replace dynamic checks with if (false) since this is for
|
|
|
|
// browser only. Rollup's dead code elimination will remove
|
|
|
|
// any code guarded by if (isNode) { ... }
|
2018-09-28 13:43:58 +03:00
|
|
|
"if (isNode)": "if (false)"
|
2018-09-26 06:08:03 +03:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
// os is not used by the browser bundle, so just shim it
|
|
|
|
shim({
|
|
|
|
os: `
|
2018-09-28 13:43:58 +03:00
|
|
|
export const type = 1;
|
|
|
|
export const release = 1;
|
|
|
|
`
|
2018-09-26 06:08:03 +03:00
|
|
|
}),
|
|
|
|
nodeResolve({
|
|
|
|
module: true,
|
|
|
|
browser: true,
|
|
|
|
preferBuiltins: false
|
|
|
|
}),
|
|
|
|
commonjs({
|
|
|
|
namedExports: {
|
2018-09-28 13:43:58 +03:00
|
|
|
events: ["EventEmitter"],
|
|
|
|
assert: ["ok", "deepEqual", "equal", "fail", "deepStrictEqual"]
|
2018-09-26 06:08:03 +03:00
|
|
|
}
|
2018-09-28 13:43:58 +03:00
|
|
|
})
|
2018-09-26 06:08:03 +03:00
|
|
|
]
|
2018-09-28 13:43:58 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
if (isProduction) {
|
|
|
|
browserRollupConfig.output.file = "browser/azure-storage.blob.min.js";
|
|
|
|
browserRollupConfig.plugins.push(
|
|
|
|
uglify({
|
|
|
|
output: {
|
|
|
|
preamble: banner
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
2018-09-26 06:08:03 +03:00
|
|
|
}
|
2018-09-28 13:43:58 +03:00
|
|
|
|
|
|
|
return browserRollupConfig;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default [
|
|
|
|
nodeRollupConfigFactory(),
|
|
|
|
browserRollupConfigFactory(true),
|
|
|
|
browserRollupConfigFactory(false)
|
2018-09-26 06:08:03 +03:00
|
|
|
];
|