Merge pull request #403 from uhrjun/master
Updated dependencies and build refactor
This commit is contained in:
commit
79a9424be5
20
.babelrc
20
.babelrc
@ -1,14 +1,10 @@
|
|||||||
{
|
{
|
||||||
"presets": [
|
"presets": [
|
||||||
["latest", {
|
["@babel/preset-env", {
|
||||||
"es2015": {
|
"targets": {
|
||||||
"modules": false
|
"browsers": ["last 2 versions", "safari >= 7"]
|
||||||
}
|
},
|
||||||
}]
|
"modules": false
|
||||||
],
|
}]
|
||||||
"env": {
|
]
|
||||||
"test": {
|
|
||||||
"presets": ["env"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
114
package.json
114
package.json
@ -1,67 +1,51 @@
|
|||||||
{
|
{
|
||||||
"name": "frappe-charts",
|
"name": "frappe-charts",
|
||||||
"version": "1.6.3",
|
"version": "v1.6.3",
|
||||||
"description": "https://frappe.github.io/charts",
|
"type": "module",
|
||||||
"main": "dist/frappe-charts.min.cjs.js",
|
"main": "dist/frappe-charts.esm.js",
|
||||||
"module": "dist/frappe-charts.min.esm.js",
|
"module": "dist/frappe-charts.esm.js",
|
||||||
"src": "dist/frappe-charts.esm.js",
|
"browser": "dist/frappe-charts.umd.js",
|
||||||
"browser": "dist/frappe-charts.min.umd.js",
|
"common": "dist/frappe-charts.cjs.js",
|
||||||
"directories": {
|
"unnpkg": "dist/frappe-charts.umd.js",
|
||||||
"doc": "docs"
|
"description": "https://frappe.github.io/charts",
|
||||||
},
|
"directories": {
|
||||||
"files": [
|
"doc": "docs"
|
||||||
"src",
|
},
|
||||||
"dist"
|
"files": [
|
||||||
],
|
"src",
|
||||||
"scripts": {
|
"dist"
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
],
|
||||||
"watch": "rollup -c --watch",
|
"scripts": {
|
||||||
"dev": "npm-run-all --parallel watch",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"build": "rollup -c"
|
"watch": "rollup -c --watch",
|
||||||
},
|
"dev": "npm-run-all --parallel watch",
|
||||||
"repository": {
|
"build": "rollup -c"
|
||||||
"type": "git",
|
},
|
||||||
"url": "git+https://github.com/frappe/charts.git"
|
"repository": {
|
||||||
},
|
"type": "git",
|
||||||
"keywords": [
|
"url": "git+https://github.com/frappe/charts.git"
|
||||||
"js",
|
},
|
||||||
"charts"
|
"keywords": [
|
||||||
],
|
"js",
|
||||||
"author": "Prateeksha Singh",
|
"charts"
|
||||||
"license": "MIT",
|
],
|
||||||
"bugs": {
|
"author": "Prateeksha Singh",
|
||||||
"url": "https://github.com/frappe/charts/issues"
|
"license": "MIT",
|
||||||
},
|
"bugs": {
|
||||||
"homepage": "https://github.com/frappe/charts#readme",
|
"url": "https://github.com/frappe/charts/issues"
|
||||||
"devDependencies": {
|
},
|
||||||
"autoprefixer": "^8.1.0",
|
"homepage": "https://github.com/frappe/charts#readme",
|
||||||
"babel-core": "^6.26.3",
|
"devDependencies": {
|
||||||
"babel-plugin-external-helpers": "^6.22.0",
|
"@babel/core": "^7.10.5",
|
||||||
"babel-plugin-istanbul": "^5.1.4",
|
"@babel/preset-env": "^7.10.4",
|
||||||
"babel-preset-env": "^1.7.0",
|
"node-sass": "^8.0.0",
|
||||||
"babel-preset-latest": "^6.24.1",
|
"rollup": "^2.21.0",
|
||||||
"babel-register": "^6.26.0",
|
"rollup-plugin-babel": "^4.4.0",
|
||||||
"clean-css": "^4.1.11",
|
"rollup-plugin-bundle-size": "^1.0.3",
|
||||||
"coveralls": "^3.0.0",
|
"rollup-plugin-commonjs": "^10.1.0",
|
||||||
"cross-env": "^5.1.4",
|
"rollup-plugin-eslint": "^7.0.0",
|
||||||
"cssnano": "^4.1.10",
|
"rollup-plugin-postcss": "^3.1.3",
|
||||||
"eslint": "^8.9.0",
|
"rollup-plugin-scss": "^2.5.0",
|
||||||
"mocha": "^9.2.0",
|
"rollup-plugin-terser": "^6.1.0"
|
||||||
"node-sass": "^7.0.1",
|
}
|
||||||
"npm-run-all": "^4.1.2",
|
|
||||||
"nyc": "^15.1.0",
|
|
||||||
"postcss": "^6.0.21",
|
|
||||||
"postcss-cssnext": "^3.1.0",
|
|
||||||
"postcss-nested": "^3.0.0",
|
|
||||||
"precss": "^3.1.2",
|
|
||||||
"rollup": "^0.56.5",
|
|
||||||
"rollup-plugin-babel": "^3.0.3",
|
|
||||||
"rollup-plugin-eslint": "^6.0.0",
|
|
||||||
"rollup-plugin-node-resolve": "^3.3.0",
|
|
||||||
"rollup-plugin-postcss": "^2.0.3",
|
|
||||||
"rollup-plugin-replace": "^2.0.0",
|
|
||||||
"rollup-plugin-uglify": "^2.0.1",
|
|
||||||
"rollup-plugin-uglify-es": "0.0.1",
|
|
||||||
"rollup-watch": "^4.3.1"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
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