chore: fixed build rewrite (frontported)
The fix is naming the umd module frappe instead of frappe charts
This commit is contained in:
parent
62683ea32d
commit
bf068ec6ea
231
rollup.config.js
231
rollup.config.js
@ -1,196 +1,47 @@
|
|||||||
import pkg from "./package.json";
|
import pkg from "./package.json";
|
||||||
|
|
||||||
// Rollup plugins
|
import commonjs from "rollup-plugin-commonjs";
|
||||||
import babel from "rollup-plugin-babel";
|
import babel from "rollup-plugin-babel";
|
||||||
import { eslint } from "rollup-plugin-eslint";
|
import postcss from "rollup-plugin-postcss";
|
||||||
import replace from "rollup-plugin-replace";
|
import scss from "rollup-plugin-scss";
|
||||||
import uglify from "rollup-plugin-uglify-es";
|
import bundleSize from "rollup-plugin-bundle-size";
|
||||||
import sass from "node-sass";
|
import { terser } from "rollup-plugin-terser";
|
||||||
|
|
||||||
// PostCSS plugins
|
|
||||||
import postcssPlugin from "rollup-plugin-postcss";
|
|
||||||
import nested from "postcss-nested";
|
|
||||||
import cssnext from "postcss-cssnext";
|
|
||||||
import cssnano from "cssnano";
|
|
||||||
|
|
||||||
import postcss from "postcss";
|
|
||||||
import precss from "precss";
|
|
||||||
import CleanCSS from "clean-css";
|
|
||||||
import autoprefixer from "autoprefixer";
|
|
||||||
import fs from "fs";
|
|
||||||
|
|
||||||
fs.readFile("src/css/charts.scss", (err, css) => {
|
|
||||||
postcss([precss, autoprefixer])
|
|
||||||
.process(css, { from: "src/css/charts.scss", to: "src/css/charts.css" })
|
|
||||||
.then((result) => {
|
|
||||||
let options = {
|
|
||||||
level: {
|
|
||||||
1: {
|
|
||||||
removeQuotes: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
let output = new CleanCSS(options).minify(result.css);
|
|
||||||
let res = JSON.stringify(output.styles).replace(/"/g, "'");
|
|
||||||
let js = `export const CSSTEXT = "${res.slice(1, -1)}";`;
|
|
||||||
fs.writeFile("src/css/chartsCss.js", js, (err) => {
|
|
||||||
if (err) console.log(err);
|
|
||||||
else {
|
|
||||||
console.log("File written successfully\n");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
{
|
// browser-friendly UMD build
|
||||||
input: "src/js/index.js",
|
{
|
||||||
sourcemap: true,
|
input: "src/js/index.js",
|
||||||
output: [
|
output: {
|
||||||
{
|
sourcemap: true,
|
||||||
file: "docs/assets/js/frappe-charts.min.js",
|
name: "frappe",
|
||||||
format: "iife",
|
file: pkg.browser,
|
||||||
},
|
format: "umd",
|
||||||
{
|
},
|
||||||
file: pkg.browser,
|
plugins: [
|
||||||
format: "umd",
|
commonjs(),
|
||||||
},
|
babel({
|
||||||
],
|
exclude: ["node_modules/**"],
|
||||||
name: "frappe",
|
}),
|
||||||
plugins: [
|
terser(),
|
||||||
postcssPlugin({
|
scss({ output: "dist/frappe-charts.min.css" }),
|
||||||
preprocessor: (content, id) =>
|
bundleSize(),
|
||||||
new Promise((resolve, reject) => {
|
],
|
||||||
const result = sass.renderSync({ file: id });
|
},
|
||||||
resolve({ code: result.css.toString() });
|
|
||||||
}),
|
// CommonJS (for Node) and ES module (for bundlers) build.
|
||||||
extensions: [".scss"],
|
{
|
||||||
plugins: [
|
input: "src/js/chart.js",
|
||||||
nested(),
|
output: [
|
||||||
cssnext({ warnForDuplicates: false }),
|
{ file: pkg.common, format: "cjs", sourcemap: true },
|
||||||
cssnano(),
|
{ file: pkg.module, format: "es", sourcemap: true },
|
||||||
],
|
],
|
||||||
}),
|
plugins: [
|
||||||
eslint({
|
babel({
|
||||||
exclude: ["src/css/**"],
|
exclude: ["node_modules/**"],
|
||||||
}),
|
}),
|
||||||
babel({
|
terser(),
|
||||||
exclude: "node_modules/**",
|
postcss(),
|
||||||
plugins: ["external-helpers"],
|
bundleSize(),
|
||||||
}),
|
],
|
||||||
replace({
|
},
|
||||||
exclude: "node_modules/**",
|
|
||||||
ENV: JSON.stringify(process.env.NODE_ENV || "development"),
|
|
||||||
}),
|
|
||||||
uglify(),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
input: "docs/assets/js/index.js",
|
|
||||||
sourcemap: true,
|
|
||||||
output: [
|
|
||||||
{
|
|
||||||
file: "docs/assets/js/index.min.js",
|
|
||||||
format: "iife",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
name: "frappe",
|
|
||||||
plugins: [
|
|
||||||
postcssPlugin({
|
|
||||||
preprocessor: (content, id) =>
|
|
||||||
new Promise((resolve, reject) => {
|
|
||||||
const result = sass.renderSync({ file: id });
|
|
||||||
resolve({ code: result.css.toString() });
|
|
||||||
}),
|
|
||||||
extensions: [".scss"],
|
|
||||||
plugins: [
|
|
||||||
nested(),
|
|
||||||
cssnext({ warnForDuplicates: false }),
|
|
||||||
cssnano(),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
eslint({
|
|
||||||
exclude: ["src/css/**"],
|
|
||||||
}),
|
|
||||||
babel({
|
|
||||||
exclude: "node_modules/**",
|
|
||||||
}),
|
|
||||||
replace({
|
|
||||||
exclude: "node_modules/**",
|
|
||||||
ENV: JSON.stringify(process.env.NODE_ENV || "development"),
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
input: "src/js/chart.js",
|
|
||||||
sourcemap: true,
|
|
||||||
output: [
|
|
||||||
{
|
|
||||||
file: pkg.main,
|
|
||||||
format: "cjs",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
file: pkg.module,
|
|
||||||
format: "es",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
plugins: [
|
|
||||||
postcssPlugin({
|
|
||||||
preprocessor: (content, id) =>
|
|
||||||
new Promise((resolve, reject) => {
|
|
||||||
const result = sass.renderSync({ file: id });
|
|
||||||
resolve({ code: result.css.toString() });
|
|
||||||
}),
|
|
||||||
extensions: [".scss"],
|
|
||||||
plugins: [
|
|
||||||
nested(),
|
|
||||||
cssnext({ warnForDuplicates: false }),
|
|
||||||
cssnano(),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
eslint({
|
|
||||||
exclude: ["src/css/**"],
|
|
||||||
}),
|
|
||||||
babel({
|
|
||||||
exclude: "node_modules/**",
|
|
||||||
}),
|
|
||||||
replace({
|
|
||||||
exclude: "node_modules/**",
|
|
||||||
ENV: JSON.stringify(process.env.NODE_ENV || "development"),
|
|
||||||
}),
|
|
||||||
uglify(),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
input: "src/js/chart.js",
|
|
||||||
output: [
|
|
||||||
{
|
|
||||||
file: pkg.src,
|
|
||||||
format: "es",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
plugins: [
|
|
||||||
postcssPlugin({
|
|
||||||
preprocessor: (content, id) =>
|
|
||||||
new Promise((resolve, reject) => {
|
|
||||||
const result = sass.renderSync({ file: id });
|
|
||||||
resolve({ code: result.css.toString() });
|
|
||||||
}),
|
|
||||||
extensions: [".scss"],
|
|
||||||
extract: "dist/frappe-charts.min.css",
|
|
||||||
plugins: [
|
|
||||||
nested(),
|
|
||||||
cssnext({ warnForDuplicates: false }),
|
|
||||||
cssnano(),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
eslint({
|
|
||||||
exclude: ["src/css/**"],
|
|
||||||
}),
|
|
||||||
replace({
|
|
||||||
exclude: "node_modules/**",
|
|
||||||
ENV: JSON.stringify(process.env.NODE_ENV || "development"),
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user