Skip to content
This repository was archived by the owner on Feb 22, 2021. It is now read-only.

Commit 5e1f2f1

Browse files
authored
Merge pull request #1 from WittBulter/init
feat: init
2 parents 7ebfe5a + 795acb9 commit 5e1f2f1

27 files changed

+11056
-1
lines changed

.github/CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
DhyanaChina Contributing Guide
2+
3+
### Pull Request Guidelines
4+
- Fork this repository to your own account. Do not create branches here.
5+
- Commit info should be formatted by the [rules](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-guidelines).
6+
- Rebase before creating a PR to keep commit history clear.
7+
- Merging a PR takes two maintainers: one approves the changes after reviewing, and then the other reviews and merges.
8+
9+
### Code Style
10+
Follow TSLint
11+

.github/ISSUE_TEMPLATE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Type:
2+
- [ ] Bug
3+
- [ ] Feature
4+
- [ ] Help
5+
6+
Version:
7+
8+
9+
Description:
10+
11+

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## PR Checklist
2+
3+
- [ ] Fix linting errors
4+
- [ ] Label has been added
5+
6+
7+
## Change information
8+
9+

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,11 @@ typings/
5757
# dotenv environment variables file
5858
.env
5959

60+
# build scripts
61+
build/**/*.js
62+
dist/
63+
release/
64+
65+
# cover report
66+
coverage/
67+
.nyc_output/

.travis.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
language: node_js
3+
4+
node_js:
5+
- 8.6.0
6+
7+
branches:
8+
only:
9+
- master
10+
11+
before_install: git fetch --depth=1000
12+
13+
install:
14+
- npm i -g typescript webpack
15+
- npm i
16+
17+
script:
18+
- /bin/bash build/lint-commits.sh
19+
- npm run ex:build && npm run release
20+
21+
after_success:
22+
- npm run cover

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,28 @@
1-
# back-loader
1+
### back-loader
2+
3+
4+
#### Usage
5+
6+
1. install: `npm i back-loader --save`
7+
8+
2. use:
9+
```ts
10+
import { BackLoader } from 'back-loader'
11+
12+
const backHandler = new BackLoader({
13+
urls: string[],
14+
scripts: string[],
15+
styles: string[],
16+
images: string[],
17+
})
18+
19+
// at the right time:
20+
backHandler.start()
21+
backHandler.onload = (event: any) => {
22+
console.log(event)
23+
}
24+
```
25+
26+
#### LICENSE
27+
28+
**MIT**

build/lint-commits.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# lint-commits.sh
2+
#!/bin/bash
3+
set -e
4+
set -u
5+
6+
if [[ $TRAVIS_PULL_REQUEST_SLUG != "" && $TRAVIS_PULL_REQUEST_SLUG != $TRAVIS_REPO_SLUG ]]; then
7+
# This is a Pull Request from a different slug, hence a forked repository
8+
git remote add "$TRAVIS_PULL_REQUEST_SLUG" "https://github.com/$TRAVIS_PULL_REQUEST_SLUG.git"
9+
git fetch "$TRAVIS_PULL_REQUEST_SLUG"
10+
11+
# Use the fetched remote pointing to the source clone for comparison
12+
TO="$TRAVIS_PULL_REQUEST_SLUG/$TRAVIS_PULL_REQUEST_BRANCH"
13+
else
14+
# This is a Pull Request from the same remote, no clone repository
15+
TO=$TRAVIS_COMMIT
16+
fi
17+
18+
19+
# Lint all commits in the PR
20+
# - Covers fork pull requests (when TO=slug/branch)
21+
# - Covers branch pull requests (when TO=branch)
22+
./node_modules/.bin/commitlint --from="$TRAVIS_BRANCH" --to="$TO"
23+
24+
# Always lint the triggerig commit
25+
# - Covers direct commits
26+
./node_modules/.bin/commitlint --from="$TRAVIS_COMMIT"

build/main/webpack.prod.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import * as path from 'path'
2+
import * as webpack from 'webpack'
3+
const tslintConfig = require('../../tslint.json')
4+
5+
module.exports = {
6+
7+
entry: {
8+
'back-loader': [path.resolve(__dirname, '../../src/index.ts')],
9+
},
10+
11+
output: {
12+
path: path.resolve(__dirname, '../../release'),
13+
filename: '[name].js',
14+
},
15+
16+
resolve: {
17+
extensions: ['.ts', '.js'],
18+
},
19+
20+
module: {
21+
rules: [
22+
{
23+
test: /\.ts/,
24+
enforce: 'pre',
25+
exclude: /node_modules/,
26+
loader: 'tslint-loader',
27+
options: {
28+
configuration: tslintConfig,
29+
},
30+
},
31+
{
32+
test: /\.ts$/,
33+
loaders: [
34+
{
35+
loader: 'awesome-typescript-loader',
36+
options: { configFileName: path.resolve(__dirname, '../../tsconfig.json') },
37+
},
38+
],
39+
},
40+
],
41+
42+
exprContextCritical: false,
43+
},
44+
45+
plugins: [
46+
new webpack.NoEmitOnErrorsPlugin(),
47+
],
48+
}

build/webpack.base.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import * as webpack from 'webpack'
2+
import * as path from 'path'
3+
const tslintConfig = require('../tslint.json')
4+
5+
module.exports = {
6+
7+
resolve: {
8+
extensions: ['.ts', '.js'],
9+
},
10+
11+
module: {
12+
rules: [
13+
{
14+
test: /\.ts/,
15+
enforce: 'pre',
16+
exclude: /node_modules/,
17+
loader: 'tslint-loader',
18+
options: {
19+
configuration: tslintConfig,
20+
},
21+
},
22+
{
23+
test: /\.ts$/,
24+
loaders: [
25+
{
26+
loader: 'awesome-typescript-loader',
27+
options: { configFileName: path.resolve(__dirname, '../examples/tsconfig.json') },
28+
},
29+
],
30+
},
31+
],
32+
33+
exprContextCritical: false,
34+
},
35+
36+
plugins: [
37+
38+
new webpack.optimize.CommonsChunkPlugin({
39+
names: ['app'],
40+
}),
41+
42+
],
43+
}

build/webpack.dev.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import * as path from 'path'
2+
import * as webpackBase from './webpack.base'
3+
import * as webpackMerge from 'webpack-merge'
4+
import * as HtmlWebpackPlugin from 'html-webpack-plugin'
5+
6+
module.exports = webpackMerge(webpackBase, {
7+
8+
devtool: 'cheap-module-eval-source-map',
9+
10+
entry: {
11+
'app': [path.resolve(__dirname, '../examples/main.ts')],
12+
},
13+
14+
output: {
15+
path: path.resolve(__dirname, '../dist/output'),
16+
filename: '[name].js',
17+
chunkFilename: '[id].chunk.js'
18+
},
19+
20+
plugins: [
21+
new HtmlWebpackPlugin({
22+
template: path.resolve(__dirname, '../examples/template.html'),
23+
}),
24+
],
25+
26+
})

0 commit comments

Comments
 (0)