Skip to content

Commit

Permalink
build: speed up storybook build (apache#160)
Browse files Browse the repository at this point in the history
* build: speedup storybook build

* build: noParse for jquery and d3

* fix: remove unused

* build: add more ignore

* fix: broken build

* fix: adjust list of modules

* fix: adjust list of modules

* fix: adjust list of modules

* fix: adjust list of modules

* fix: adjust list of modules

* fix: adjust list of modules

* build: reduce parellism

* fix: reduce parellism

* fix: reduce parellism

* fix: try

* fix: remove src import

* fix: list of lib

* fix: list of lib

* fix: keep fixing

* fix: keep fixing

* fix: disable mapbox

* fix: bug

* fix: disable another

* fix: remove unused commands

* fix: add comments
  • Loading branch information
kristw authored and zhaoyongjie committed Nov 24, 2021
1 parent 090b770 commit 71598e9
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const path = require('path');
const TerserPlugin = require('terser-webpack-plugin');
const webpack = require('webpack');

const BABEL_TYPESCRIPT_OPTIONS = {
presets: [
Expand All @@ -7,6 +9,7 @@ const BABEL_TYPESCRIPT_OPTIONS = {
'@babel/preset-typescript',
],
plugins: [
'lodash',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-syntax-dynamic-import',
Expand All @@ -20,6 +23,16 @@ const SIBLING_PACKAGES_PATH_REGEXP = new RegExp(
module.exports = async ({ config }) => {
config.resolve = config.resolve || {};
config.resolve.extensions = ['.tsx', '.ts', '.jsx', '.js'];
config.resolve.alias = {
...config.resolve.alias,
d3$: path.resolve(__dirname, '../../../node_modules/d3/d3.min.js'),
nvd3$: path.resolve(__dirname, '../../../node_modules/nvd3/build/nv.d3.min.js'),
'datatables.net$': path.resolve(__dirname, '../../../node_modules/datatables.net/js/jquery.dataTables.min.js'),
}

config.plugins.push(new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/));
// Avoid parsing large libraries to speed up build
config.module.noParse = /jquery|moment/;

// To enable live debugging of other packages when referring to `src`
config.module.rules.push({
Expand All @@ -41,6 +54,7 @@ module.exports = async ({ config }) => {
});

config.module.rules.push({
include: path.resolve(__dirname, '../storybook'),
exclude: /node_modules/,
test: /\.tsx?$/,
use: [{
Expand All @@ -49,5 +63,21 @@ module.exports = async ({ config }) => {
}],
});

config.optimization = config.optimization || {};
config.optimization.splitChunks = {
chunks: 'async'
};
config.optimization.minimizer = [
new TerserPlugin({
parallel: true,
extractComments: true,
}),
];

if (process.env.RUNNING_CONTEXT === 'netlify') {
config.devtool = false;
config.cache = false;
}

return config;
};
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"@babel/core": "^7.4.3",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"babel-loader": "^8.0.5",
"gh-pages": "^2.0.1"
"gh-pages": "^2.0.1",
"terser-webpack-plugin": "1.3.0"
},
"peerDependencies": {
"@superset-ui/chart": "^0.11.13",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import CountryMapChartPlugin from '../../../../superset-ui-legacy-plugin-chart-country-map';
import Stories from './Stories';
// Disable temporarily

new CountryMapChartPlugin().configure({ key: 'country-map' }).register();
// import CountryMapChartPlugin from '../../../../superset-ui-legacy-plugin-chart-country-map';
// import Stories from './Stories';

export default {
examples: [...Stories],
};
// new CountryMapChartPlugin().configure({ key: 'country-map' }).register();

// export default {
// examples: [...Stories],
// };
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import MapBoxChartPlugin from '../../../../superset-ui-legacy-plugin-chart-map-box';
import Stories from './Stories';
// Disable temporarily

new MapBoxChartPlugin().configure({ key: 'map-box' }).register();
// import MapBoxChartPlugin from '../../../../superset-ui-legacy-plugin-chart-map-box';
// import Stories from './Stories';

export default {
examples: [...Stories],
};
// new MapBoxChartPlugin().configure({ key: 'map-box' }).register();

// export default {
// examples: [...Stories],
// };
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BoxPlotChartPlugin as LegacyBoxPlotChartPlugin } from '../../../../../superset-ui-preset-chart-xy/src/legacy';
import { BoxPlotChartPlugin } from '../../../../../superset-ui-preset-chart-xy/src';
import { BoxPlotChartPlugin as LegacyBoxPlotChartPlugin } from '../../../../../superset-ui-preset-chart-xy/esm/legacy';
import { BoxPlotChartPlugin } from '../../../../../superset-ui-preset-chart-xy';
import Stories from './stories/Basic';
import LegacyStories from './stories/Legacy';
import { BOX_PLOT_PLUGIN_LEGACY_TYPE, BOX_PLOT_PLUGIN_TYPE } from './constants';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LineChartPlugin as LegacyLineChartPlugin } from '../../../../../superset-ui-preset-chart-xy/src/legacy';
import { LineChartPlugin } from '../../../../../superset-ui-preset-chart-xy/src';
import { LineChartPlugin as LegacyLineChartPlugin } from '../../../../../superset-ui-preset-chart-xy/esm/legacy';
import { LineChartPlugin } from '../../../../../superset-ui-preset-chart-xy';
import BasicStories from './stories/basic';
import FlushStories from './stories/flush';
import QueryStories from './stories/query';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ScatterPlotPlugin as LegacyScatterPlotPlugin } from '../../../../../superset-ui-preset-chart-xy/src/legacy';
import { ScatterPlotPlugin } from '../../../../../superset-ui-preset-chart-xy/src';
import { ScatterPlotPlugin as LegacyScatterPlotPlugin } from '../../../../../superset-ui-preset-chart-xy/esm/legacy';
import { ScatterPlotPlugin } from '../../../../../superset-ui-preset-chart-xy';
import BasicStories from './stories/basic';
import BubbleStories from './stories/bubble';
import LegacyStories from './stories/legacy';
Expand Down

0 comments on commit 71598e9

Please sign in to comment.