Skip to content
This repository was archived by the owner on May 29, 2022. It is now read-only.

Commit 3ffb7e9

Browse files
committed
feat(all): initial commit
0 parents  commit 3ffb7e9

File tree

12 files changed

+182
-0
lines changed

12 files changed

+182
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/node_modules
2+
.idea
3+
.vscode
4+
npm-debug.log*
5+
/typings
6+
/dist

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/typings
2+
/.vscode

.travis.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
sudo: false
2+
language: node_js
3+
cache:
4+
directories:
5+
- node_modules
6+
notifications:
7+
email: false
8+
node_js:
9+
- 6
10+
before_install:
11+
- npm i -g npm
12+
before_script:
13+
- npm prune
14+
- npm install @easy-webpack/core webpack@beta
15+
after_success:
16+
- npm run semantic-release
17+
branches:
18+
except:
19+
- /^v\d+\.\d+\.\d+$/

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2016 Bazyli Brzóska
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare module 'awesome-typescript-loader' {
2+
export class ForkCheckerPlugin {}
3+
}

package.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"name": "@easy-webpack/config-typescript",
3+
"description": "Easy Webpack configuration function for typescript",
4+
"main": "dist/index.js",
5+
"typings": "dist/index.d.ts",
6+
"scripts": {
7+
"test": "TS_NODE_FAST=true TS_NODE_NO_PROJECT=true ava",
8+
"postinstall": "typings install",
9+
"build": "rimraf dist && tsc -p .",
10+
"semantic-release": "npm run build && semantic-release pre && npm publish --access=public && semantic-release post"
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "https://github.com/easy-webpack/config-typescript.git"
15+
},
16+
"keywords": [
17+
"typescript",
18+
"webpack",
19+
"easy",
20+
"configurator",
21+
"configuration",
22+
"config",
23+
"simple"
24+
],
25+
"author": "Bazyli Brzóska <[email protected]> (https://invent.life)",
26+
"license": "MIT",
27+
"bugs": {
28+
"url": "https://github.com/easy-webpack/config-typescript/issues"
29+
},
30+
"homepage": "https://github.com/easy-webpack/config-typescript#readme",
31+
"devDependencies": {
32+
"ava": "^0.15.2",
33+
"semantic-release": "^4.3.5",
34+
"ts-node": "^0.9.1",
35+
"tslint": "^3.11.0",
36+
"tslint-config-standard": "^1.2.2",
37+
"typescript": ">=1.9.0-dev.20160619-1.0 || ^2.0.0",
38+
"typings": "^1.3.0"
39+
},
40+
"dependencies": {
41+
"awesome-typescript-loader": "^1.1.1",
42+
"babel-core": "^6.9.1",
43+
"babel-preset-es2015": "^6.9.0",
44+
"babel-preset-es2015-loose": "^7.0.0",
45+
"babel-preset-es2015-loose-native-modules": "^1.0.0"
46+
},
47+
"peerDependencies": {
48+
"@easy-webpack/core": "*"
49+
},
50+
"ava": {
51+
"files": [
52+
"test/**/*.{ts,js}"
53+
],
54+
"tap": false,
55+
"require": [
56+
"ts-node/register"
57+
]
58+
}
59+
}

src/index.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import {WebpackConfig, get} from '@easy-webpack/core'
2+
import * as path from 'path'
3+
import {ForkCheckerPlugin} from 'awesome-typescript-loader'
4+
5+
/**
6+
* Typescript loader support for .ts
7+
* See: https://github.com/s-panferov/awesome-typescript-loader
8+
*/
9+
export function typescript(options = {}, exclude: Array<string> = null) {
10+
return function typescript(this: WebpackConfig): WebpackConfig {
11+
return {
12+
resolve: {
13+
extensions: get(this, 'resolve.extensions', ['', '.js']).concat(['.ts'])
14+
},
15+
module: {
16+
loaders: get(this, 'module.loaders', []).concat([{
17+
test: /\.tsx?$/,
18+
loader: 'awesome-typescript',
19+
exclude: exclude || this.metadata.root ? [path.join(this.metadata.root, 'node_modules')] : [],
20+
query: options
21+
}])
22+
},
23+
plugins: [
24+
/*
25+
* Plugin: ForkCheckerPlugin
26+
* Description: Do type checking in a separate process, so webpack don't need to wait.
27+
*
28+
* See: https://github.com/s-panferov/awesome-typescript-loader#forkchecker-boolean-defaultfalse
29+
*/
30+
new ForkCheckerPlugin()
31+
].concat(get(this, 'plugins', []))
32+
}
33+
}
34+
}

test/config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import test from 'ava'
2+
import {assign} from '../src'
3+
4+
test(`dummy`, t => {
5+
t.true(true)
6+
})

tsconfig.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "commonjs",
5+
"experimentalDecorators": true,
6+
"moduleResolution": "node",
7+
"allowJs": false,
8+
"declaration": true,
9+
"outDir": "dist",
10+
"rootDir": "src",
11+
"sourceMap": true,
12+
"lib": ["es6"]
13+
},
14+
"exclude": [
15+
"node_modules",
16+
"dist",
17+
"test",
18+
"example"
19+
]
20+
}

0 commit comments

Comments
 (0)