Skip to content

Commit d6a32fc

Browse files
author
缺小小
committed
init: init project
1 parent dcdbba9 commit d6a32fc

19 files changed

+8855
-0
lines changed

.babelrc

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"presets": [
3+
[
4+
"env",
5+
{
6+
"targets": {
7+
"browsers": [
8+
"last 2 versions",
9+
"safari >= 7",
10+
"ie >= 10"
11+
]
12+
}
13+
}
14+
]
15+
]
16+
}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ build/Release
3535
# Dependency directories
3636
node_modules/
3737
jspm_packages/
38+
dist/
3839

3940
# TypeScript v1 declaration files
4041
typings/

package-lock.json

+8,560
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "webpack-typescript-starter",
3+
"version": "0.0.1",
4+
"license": "MIT",
5+
"scripts": {
6+
"start": "webpack-dev-server --config webpack.dev.js --port=3100",
7+
"build": "webpack --config webpack.dev.js",
8+
"build:prod": "webpack --config webpack.prod.js"
9+
},
10+
"devDependencies": {
11+
"@babel/core": "^7.6.4",
12+
"@babel/preset-env": "^7.6.3",
13+
"babel-loader": "^8.0.6",
14+
"babel-preset-env": "^1.7.0",
15+
"clean-webpack-plugin": "^3.0.0",
16+
"copy-webpack-plugin": "^5.0.4",
17+
"css-loader": "^3.2.0",
18+
"html-webpack-plugin": "^3.2.0",
19+
"mini-css-extract-plugin": "^0.8.0",
20+
"node-sass": "^4.13.0",
21+
"sass-loader": "^8.0.0",
22+
"style-loader": "^1.0.0",
23+
"ts-loader": "^6.2.1",
24+
"typescript": "^3.6.4",
25+
"webpack": "^4.41.2",
26+
"webpack-cli": "^3.3.9",
27+
"webpack-merge": "^4.2.2"
28+
}
29+
}

src/app/application.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
export class Application {
3+
4+
public hello() {
5+
console.log(
6+
`%chello %cworld %c!`,
7+
'color: red; background: lightblue; padding: 0.5rem; font-size: 14px; font-weight: bold;',
8+
'color: lightblue; background: red; padding: 0.5rem; font-size: 14px; font-weight: bold;',
9+
'color: white; background: darkgreen; padding: 0.5rem; font-size: 14px; font-weight: bold;',
10+
);
11+
}
12+
13+
}

src/assets/background.png

22.5 KB
Loading

src/assets/bird/bird.json

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{
2+
"frames": {
3+
"bird-0.png": {
4+
"frame": {
5+
"x": 0,
6+
"y": 0,
7+
"w": 92,
8+
"h": 64
9+
},
10+
"rotated": false,
11+
"trimmed": false,
12+
"spriteSourceSize": {
13+
"x": 0,
14+
"y": 0,
15+
"w": 92,
16+
"h": 64
17+
},
18+
"sourceSize": {
19+
"w": 92,
20+
"h": 64
21+
}
22+
},
23+
"bird-1.png": {
24+
"frame": {
25+
"x": 92,
26+
"y": 0,
27+
"w": 92,
28+
"h": 64
29+
},
30+
"rotated": false,
31+
"trimmed": false,
32+
"spriteSourceSize": {
33+
"x": 0,
34+
"y": 0,
35+
"w": 92,
36+
"h": 64
37+
},
38+
"sourceSize": {
39+
"w": 92,
40+
"h": 64
41+
}
42+
},
43+
"bird-2.png": {
44+
"frame": {
45+
"x": 184,
46+
"y": 0,
47+
"w": 92,
48+
"h": 64
49+
},
50+
"rotated": false,
51+
"trimmed": false,
52+
"spriteSourceSize": {
53+
"x": 0,
54+
"y": 0,
55+
"w": 92,
56+
"h": 64
57+
},
58+
"sourceSize": {
59+
"w": 92,
60+
"h": 64
61+
}
62+
}
63+
},
64+
"animations": {
65+
"bird": [
66+
"bird-0.png",
67+
"bird-1.png",
68+
"bird-2.png"
69+
]
70+
},
71+
"meta": {
72+
"app": "https://www.codeandweb.com/texturepacker",
73+
"version": "1.0",
74+
"image": "bird.png",
75+
"format": "RGBA8888",
76+
"size": {
77+
"w": 276,
78+
"h": 64
79+
},
80+
"scale": "1",
81+
"smartupdate": "$TexturePacker:SmartUpdate:726b62e7bea098e2f0736936da22598b:cf00208a7944f8a93f16e86a02974b67:6a1677158d465170d66e062b762d8e2a$"
82+
}
83+
}

src/assets/bird/bird.png

1.62 KB
Loading

src/assets/ground.png

1.23 KB
Loading

src/assets/pipe.png

3.09 KB
Loading

src/favicon.png

6.71 KB
Loading

src/index.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
6+
<link rel="shortcut icon" href="favicon.png" type="image/png" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8+
<title>Webpack Typescript Starter</title>
9+
</head>
10+
<body>
11+
12+
</body>
13+
</html>

src/main.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Application } from './app/application';
2+
3+
if(process.env.NODE_ENV !== 'production') {
4+
console.warn('Webpack is running in development mode!');
5+
}
6+
7+
new Application().hello();

src/polyfills.ts

Whitespace-only changes.

src/style.scss

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
html, body {
3+
width: 100vw;
4+
margin: 0;
5+
height: 100vh;
6+
padding: 0;
7+
overflow: hidden;
8+
}

tsconfig.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "commonjs",
5+
"sourceMap": true,
6+
"esModuleInterop": true
7+
}
8+
}

webpack.common.js

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
const HtmlWebpackPlugin = require('html-webpack-plugin');
2+
const CopyWebpackPlugin = require('copy-webpack-plugin');
3+
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
4+
5+
module.exports = {
6+
entry: {
7+
main: './src/main.ts',
8+
style: './src/style.scss',
9+
polyfills: './src/polyfills.ts',
10+
},
11+
module: {
12+
rules: [
13+
{
14+
test: /\.ts$/,
15+
use: [
16+
{
17+
loader: 'babel-loader',
18+
options: {
19+
presets: ['@babel/preset-env']
20+
},
21+
},
22+
{
23+
loader: 'ts-loader',
24+
},
25+
],
26+
exclude: /node_modules/,
27+
},
28+
{
29+
test: /\.s[ac]ss$/i,
30+
use: [
31+
'style-loader',
32+
'css-loader',
33+
'sass-loader',
34+
],
35+
},
36+
],
37+
},
38+
plugins: [
39+
new CleanWebpackPlugin(),
40+
new HtmlWebpackPlugin({
41+
template: './src/index.html',
42+
}),
43+
new CopyWebpackPlugin([
44+
{ from: './src/assets', to: 'assets' },
45+
{ from: './src/favicon.png', to: 'favicon.png' },
46+
]),
47+
],
48+
resolve: {
49+
extensions: [ '.tsx', '.ts', '.js' ],
50+
},
51+
};

webpack.dev.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const path = require('path');
2+
const merge = require('webpack-merge');
3+
const common = require('./webpack.common');
4+
5+
module.exports = merge(common, {
6+
mode: 'development',
7+
output: {
8+
path: path.resolve(__dirname, 'dist'),
9+
filename: '[name].js',
10+
},
11+
devtool: 'eval-source-map'
12+
});

webpack.prod.js

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
const path = require('path');
2+
const merge = require('webpack-merge');
3+
const common = require('./webpack.common');
4+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
5+
6+
module.exports = merge(common, {
7+
mode: 'production',
8+
output: {
9+
path: path.resolve(__dirname, 'dist'),
10+
filename: '[name].[hash].js',
11+
},
12+
module: {
13+
rules: [
14+
{
15+
test: /\.s[ac]ss$/i,
16+
use: [
17+
{
18+
loader: MiniCssExtractPlugin.loader,
19+
},
20+
{
21+
loader: 'css-loader',
22+
},
23+
{
24+
loader: 'sass-loader',
25+
},
26+
],
27+
},
28+
],
29+
},
30+
plugins: [
31+
new MiniCssExtractPlugin({
32+
filename: '[name].[hash].css',
33+
chunkFilename: '[id].[hash].css',
34+
}),
35+
],
36+
optimization: {
37+
splitChunks: {
38+
cacheGroups: {
39+
commons: {
40+
test: /[\\/]node_modules[\\/]/,
41+
name: (module, chunks, cacheGroupKey) => {
42+
const moduleFileName = module.identifier().split('/').reduceRight(item => item);
43+
// const allChunksNames = chunks.map((item) => item.name).join('~');
44+
return `${cacheGroupKey}-${moduleFileName}`;
45+
},
46+
chunks: 'all'
47+
},
48+
},
49+
},
50+
},
51+
performance: {
52+
hints: false,
53+
},
54+
});

0 commit comments

Comments
 (0)