Skip to content

Commit 80f26e4

Browse files
committed
migrate from node-sass to dart-sass
1 parent 637c3cc commit 80f26e4

File tree

8 files changed

+10807
-10198
lines changed

8 files changed

+10807
-10198
lines changed

.prettierrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"trailingComma": "none",
3+
"singleQuote": true,
4+
"arrowParens": "avoid"
5+
}

gulpfile.babel.js

+75-50
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,39 @@
1-
import gulp from 'gulp';
2-
import babel from 'gulp-babel';
3-
import sass from 'gulp-sass';
4-
import cleanCSS from 'gulp-clean-css';
5-
import cleanDir from 'gulp-clean';
6-
import rename from 'gulp-rename';
7-
import shell from 'gulp-shell';
1+
import gulp from "gulp";
2+
import babel from "gulp-babel";
3+
import gulpSass from "gulp-sass";
4+
import dartSass from "sass";
5+
import cleanCSS from "gulp-clean-css";
6+
import cleanDir from "gulp-clean";
7+
import rename from "gulp-rename";
8+
import shell from "gulp-shell";
89

9-
const LIB = 'lib';
10-
const DIST = 'dist';
11-
const TEST = 'test';
12-
const PKG_PATH = './packages';
13-
const NODE_MODULES = 'node_modules';
10+
const sass = gulpSass(dartSass);
11+
const LIB = "lib";
12+
const DIST = "dist";
13+
const TEST = "test";
14+
const PKG_PATH = "./packages";
15+
const NODE_MODULES = "node_modules";
1416

1517
const JS_PKGS = [
16-
'react-bootstrap-table2',
17-
'react-bootstrap-table2-editor',
18-
'react-bootstrap-table2-filter',
19-
'react-bootstrap-table2-overlay',
20-
'react-bootstrap-table2-paginator',
21-
'react-bootstrap-table2-toolkit'
22-
].reduce((pkg, curr) => `${curr}|${pkg}`, '');
18+
"react-bootstrap-table2",
19+
"react-bootstrap-table2-editor",
20+
"react-bootstrap-table2-filter",
21+
"react-bootstrap-table2-overlay",
22+
"react-bootstrap-table2-paginator",
23+
"react-bootstrap-table2-toolkit",
24+
].reduce((pkg, curr) => `${curr}|${pkg}`, "");
2325

2426
const JS_SKIPS = `+(${TEST}|${LIB}|${DIST}|${NODE_MODULES})`;
2527

2628
const STYLE_PKGS = [
27-
'react-bootstrap-table2',
28-
'react-bootstrap-table2-filter',
29-
'react-bootstrap-table2-paginator',
30-
'react-bootstrap-table2-toolkit',
31-
].reduce((pkg, curr) => `${curr}|${pkg}`, '');
29+
"react-bootstrap-table2",
30+
"react-bootstrap-table2-filter",
31+
"react-bootstrap-table2-paginator",
32+
"react-bootstrap-table2-toolkit",
33+
].reduce((pkg, curr) => `${curr}|${pkg}`, "");
3234

3335
const STYLE_SKIPS = `+(${NODE_MODULES})`;
3436

35-
3637
function clean() {
3738
return gulp
3839
.src(`./packages/+(${JS_PKGS})/+(${LIB}|${DIST})`, { allowEmpty: true })
@@ -43,45 +44,69 @@ function scripts() {
4344
return gulp
4445
.src([
4546
`./packages/+(${JS_PKGS})/**/*.js`,
46-
`!packages/+(${JS_PKGS})/${JS_SKIPS}/**/*.js`
47+
`!packages/+(${JS_PKGS})/${JS_SKIPS}/**/*.js`,
4748
])
4849
.pipe(babel())
49-
.pipe(rename((path) => {
50-
if (path.dirname.indexOf('src') > -1) {
51-
path.dirname = path.dirname.replace('src', `${LIB}/src`);
52-
} else {
53-
path.dirname += `/${LIB}`;
54-
}
55-
}))
50+
.pipe(
51+
rename((path) => {
52+
if (path.dirname.indexOf("src") > -1) {
53+
path.dirname = path.dirname.replace("src", `${LIB}/src`);
54+
} else {
55+
path.dirname += `/${LIB}`;
56+
}
57+
})
58+
)
5659
.pipe(gulp.dest(PKG_PATH));
5760
}
5861

5962
function styles() {
6063
return gulp
6164
.src([
6265
`./packages/+(${STYLE_PKGS})/style/**/*.scss`,
63-
`!packages/+(${STYLE_PKGS})/${STYLE_SKIPS}/**/*.scss`
66+
`!packages/+(${STYLE_PKGS})/${STYLE_SKIPS}/**/*.scss`,
6467
])
65-
.pipe(sass().on('error', sass.logError))
66-
.pipe(rename((path) => {
67-
path.dirname = path.dirname.replace('style', DIST);
68-
}))
68+
.pipe(sass().on("error", sass.logError))
69+
.pipe(
70+
rename((path) => {
71+
path.dirname = path.dirname.replace("style", DIST);
72+
})
73+
)
6974
.pipe(gulp.dest(PKG_PATH))
70-
.pipe(cleanCSS({ compatibility: 'ie8' }))
71-
.pipe(rename((path) => {
72-
path.extname = '.min.css';
73-
}))
75+
.pipe(cleanCSS({ compatibility: "ie8" }))
76+
.pipe(
77+
rename((path) => {
78+
path.extname = ".min.css";
79+
})
80+
)
7481
.pipe(gulp.dest(PKG_PATH));
7582
}
7683

7784
function umd(done) {
7885
gulp.parallel(
79-
() => gulp.src('./webpack/next.umd.babel.js').pipe(shell(['webpack --config <%= file.path %>'])),
80-
() => gulp.src('./webpack/editor.umd.babel.js').pipe(shell(['webpack --config <%= file.path %>'])),
81-
() => gulp.src('./webpack/filter.umd.babel.js').pipe(shell(['webpack --config <%= file.path %>'])),
82-
() => gulp.src('./webpack/overlay.umd.babel.js').pipe(shell(['webpack --config <%= file.path %>'])),
83-
() => gulp.src('./webpack/paginator.umd.babel.js').pipe(shell(['webpack --config <%= file.path %>'])),
84-
() => gulp.src('./webpack/toolkit.umd.babel.js').pipe(shell(['webpack --config <%= file.path %>']))
86+
() =>
87+
gulp
88+
.src("./webpack/next.umd.babel.js")
89+
.pipe(shell(["webpack --config <%= file.path %>"])),
90+
() =>
91+
gulp
92+
.src("./webpack/editor.umd.babel.js")
93+
.pipe(shell(["webpack --config <%= file.path %>"])),
94+
() =>
95+
gulp
96+
.src("./webpack/filter.umd.babel.js")
97+
.pipe(shell(["webpack --config <%= file.path %>"])),
98+
() =>
99+
gulp
100+
.src("./webpack/overlay.umd.babel.js")
101+
.pipe(shell(["webpack --config <%= file.path %>"])),
102+
() =>
103+
gulp
104+
.src("./webpack/paginator.umd.babel.js")
105+
.pipe(shell(["webpack --config <%= file.path %>"])),
106+
() =>
107+
gulp
108+
.src("./webpack/toolkit.umd.babel.js")
109+
.pipe(shell(["webpack --config <%= file.path %>"]))
85110
)();
86111
done();
87112
}
@@ -90,5 +115,5 @@ const buildJS = gulp.parallel(umd, scripts);
90115
const buildCSS = styles;
91116
const build = gulp.series(clean, gulp.parallel(buildJS, buildCSS));
92117

93-
gulp.task('prod', build);
94-
gulp.task('default', build);
118+
gulp.task("prod", build);
119+
gulp.task("default", build);

lerna.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"lerna": "2.0.0",
3-
"packages": [
4-
"packages/*"
5-
],
6-
"version": "independent"
3+
"packages": ["packages/*"],
4+
"version": "independent",
5+
"npmClient": "yarn"
76
}

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,19 @@
6464
"gulp-clean": "0.4.0",
6565
"gulp-clean-css": "3.9.2",
6666
"gulp-rename": "^1.2.2",
67-
"gulp-sass": "3.1.0",
67+
"gulp-sass": "5.1.0",
6868
"gulp-shell": "0.6.5",
6969
"html-webpack-plugin": "2.30.1",
7070
"jest": "20.0.4",
7171
"jsdom": "11.2.0",
7272
"jsdom-global": "3.0.2",
73-
"lerna": "2.8.0",
74-
"node-sass": "7.0.1",
73+
"lerna": "2.10.1",
74+
"sass": "^1.49.9",
7575
"react-test-renderer": "16.0.0",
76-
"sass-loader": "12.6.0",
76+
"sass-loader": "^9.0.3",
7777
"sinon": "3.2.1",
7878
"style-loader": "0.17.0",
79-
"webpack": "3.5.4",
79+
"webpack": "4.41.2",
8080
"webpack-dev-server": "2.7.1"
8181
},
8282
"dependencies": {

packages/react-bootstrap-table2/src/store/sort.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function comparator(a, b) {
99
if (typeof b === 'string') {
1010
result = b.localeCompare(a);
1111
} else {
12-
result = a > b ? -1 : ((a < b) ? 1 : 0);
12+
result = a > b ? -1 : a < b ? 1 : 0;
1313
}
1414
return result;
1515
}
@@ -47,6 +47,8 @@ export const nextOrder = (
4747
{ sortOrder, sortColumn },
4848
defaultOrder = Const.SORT_DESC
4949
) => {
50-
if (!sortColumn || currentSortColumn.dataField !== sortColumn.dataField) return defaultOrder;
50+
if (!sortColumn || currentSortColumn.dataField !== sortColumn.dataField) {
51+
return defaultOrder;
52+
}
5153
return sortOrder === Const.SORT_DESC ? Const.SORT_ASC : Const.SORT_DESC;
5254
};

packages/react-bootstrap-table2/test/store/sort.test.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('Sort Function', () => {
4545
const sortFunc = sinon.stub().returns(1);
4646
sortOrder = Const.SORT_DESC;
4747
sort(data, sortOrder, { ...sortColumn, sortFunc });
48-
expect(sortFunc.callCount).toBe(6);
48+
expect(sortFunc.callCount).toBe(3);
4949
});
5050
});
5151

@@ -77,7 +77,9 @@ describe('Sort Function', () => {
7777
},
7878
sortOrder: Const.SORT_DESC
7979
};
80-
expect(nextOrder(currentSortColumn, nextSort, Const.SORT_ASC)).toBe(Const.SORT_ASC);
80+
expect(nextOrder(currentSortColumn, nextSort, Const.SORT_ASC)).toBe(
81+
Const.SORT_ASC
82+
);
8183
});
8284

8385
it('should return correcly order when current sortField is eq next sort field', () => {

webpack/webpack.umd.babel.js

+37-33
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,49 @@
1-
import webpack from 'webpack';
1+
import webpack from "webpack";
22

33
module.exports = {
4-
devtool: 'source-map',
5-
externals: [{
6-
'react': {
7-
root: 'React',
8-
commonjs2: 'react',
9-
commonjs: 'react',
10-
amd: 'react'
11-
}
12-
}, {
13-
'react-dom': {
14-
root: 'ReactDOM',
15-
commonjs2: 'react-dom',
16-
commonjs: 'react-dom',
17-
amd: 'react-dom'
18-
}
19-
}],
4+
devtool: "source-map",
5+
mode: "production",
6+
externals: [
7+
{
8+
react: {
9+
root: "React",
10+
commonjs2: "react",
11+
commonjs: "react",
12+
amd: "react",
13+
},
14+
},
15+
{
16+
"react-dom": {
17+
root: "ReactDOM",
18+
commonjs2: "react-dom",
19+
commonjs: "react-dom",
20+
amd: "react-dom",
21+
},
22+
},
23+
],
2024
module: {
21-
rules: [{
22-
enforce: 'pre',
23-
test: /\.js?$/,
24-
exclude: /node_modules/,
25-
loader: 'eslint-loader'
26-
}, {
27-
test: /\.js?$/,
28-
use: ['babel-loader'],
29-
exclude: /node_modules/
30-
}]
25+
rules: [
26+
{
27+
enforce: "pre",
28+
test: /\.js?$/,
29+
exclude: /node_modules/,
30+
loader: "eslint-loader",
31+
},
32+
{
33+
test: /\.js?$/,
34+
use: ["babel-loader"],
35+
exclude: /node_modules/,
36+
},
37+
],
3138
},
3239
plugins: [
33-
new webpack.DefinePlugin({
34-
'process.env.NODE_ENV': JSON.stringify('production')
35-
}),
3640
new webpack.SourceMapDevToolPlugin(),
3741
new webpack.optimize.DedupePlugin(),
3842
new webpack.optimize.OccurrenceOrderPlugin(),
3943
new webpack.optimize.AggressiveMergingPlugin(),
4044
new webpack.optimize.UglifyJsPlugin({
4145
include: /\.min\.js$/,
42-
compress: { warnings: false }
43-
})
44-
]
46+
compress: { warnings: false },
47+
}),
48+
],
4549
};

0 commit comments

Comments
 (0)