Skip to content

Commit 9b74898

Browse files
committed
Babel 深入学习与工程实践
1 parent cc05396 commit 9b74898

33 files changed

+9634
-2
lines changed

.gitignore copy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
*/node_modules/
3+
dist/
4+
*/dist/

README.md

Lines changed: 659 additions & 2 deletions
Large diffs are not rendered by default.

babel.config.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const presets = [
2+
[
3+
"@babel/env",
4+
]
5+
]
6+
7+
const plugins = [
8+
[
9+
"@babel/plugin-transform-runtime",
10+
{
11+
corejs: 3,
12+
}
13+
]
14+
]
15+
16+
const ignore = [
17+
/^.+\.test\.js$/,
18+
/^.+\.spec\.js$/,
19+
'node_modules/**'
20+
]
21+
22+
23+
module.exports = {
24+
presets,
25+
plugins, ignore,
26+
inputSourceMap: true,
27+
sourceType: 'module',
28+
// compact: false,
29+
// minified: true,
30+
// comments: false
31+
}

examples/gulp/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

examples/gulp/babel.config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const presets = [
2+
'@babel/env',
3+
];
4+
5+
const plugins = [
6+
[
7+
'@babel/plugin-transform-runtime',
8+
{
9+
corejs: 3,
10+
}
11+
]
12+
];
13+
14+
const ignore = [
15+
'node_modules/**'
16+
];
17+
18+
module.exports = {
19+
presets,
20+
plugins,
21+
ignore,
22+
}

examples/gulp/dist/dependA.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/gulp/dist/dependB.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/gulp/dist/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/gulp/gulpfile.babel.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import gulp from 'gulp';
2+
import babel from 'gulp-babel';
3+
import uglify from 'gulp-uglify';
4+
import del from 'del';
5+
6+
const paths = {
7+
scripts: {
8+
src: 'src/**/*.js',
9+
dest: 'dist/'
10+
}
11+
};
12+
13+
const clean = () => del([ 'dist' ]);
14+
15+
const scripts = () => {
16+
return gulp.src(paths.scripts.src, { sourcemaps: true })
17+
.pipe(babel())
18+
.pipe(uglify())
19+
.pipe(gulp.dest(paths.scripts.dest));
20+
}
21+
22+
const build = gulp.series(clean, gulp.parallel(scripts));
23+
24+
export default build;
25+

examples/gulp/package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "gulp",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"build": "gulp"
9+
},
10+
"keywords": [],
11+
"author": "",
12+
"license": "ISC",
13+
"devDependencies": {
14+
"@babel/cli": "^7.5.5",
15+
"@babel/core": "^7.5.5",
16+
"@babel/plugin-transform-runtime": "^7.5.5",
17+
"@babel/preset-env": "^7.5.5",
18+
"@babel/register": "^7.5.5",
19+
"del": "^5.0.0",
20+
"gulp": "^4.0.2",
21+
"gulp-babel": "^8.0.0",
22+
"gulp-uglify": "^3.0.2"
23+
},
24+
"dependencies": {
25+
"@babel/runtime-corejs3": "^7.5.5",
26+
"lodash": "^4.17.15"
27+
}
28+
}

examples/gulp/src/dependA.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const someA = () => {
2+
console.log(Array.from('1233'));
3+
}
4+
5+
export const otherA = () => {
6+
console.log('otherA');
7+
}

examples/gulp/src/dependB.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const someB = () => {
2+
console.log('someB');
3+
}
4+
5+
export default someB

examples/gulp/src/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {someA} from './dependA';
2+
import someB from './dependB';
3+
import _ from 'lodash';
4+
5+
const a = [1,2,3].includes(3);
6+
const b = new Map();
7+
const c = new Set();
8+
console.log(a, b, c);
9+
someA();
10+
someB();
11+
_.join(['Hello', 'webpack'], ' ')

0 commit comments

Comments
 (0)