최원석3 [goesnow]

add webpack

...@@ -4,9 +4,10 @@ node_modules ...@@ -4,9 +4,10 @@ node_modules
4 crawler/chromedriver 4 crawler/chromedriver
5 crawler/chromedriver.exe 5 crawler/chromedriver.exe
6 **/*.exe 6 **/*.exe
7 +package-lock.json
7 8
8 -app/**/*.map 9 +app/build/*.map
9 -app/**/*.js 10 +app/build/*.js
10 build 11 build
11 12
12 key.py 13 key.py
......
1 build/ 1 build/
2 +gulpfile.js
3 +gulp.js
4 +webpack.config.js
......
1 +module.exports = {
2 + ...require('gts/.prettierrc.json')
3 +}
1 +
2 +const gulp = require('gulp');
3 +const browserify = require('browserify');
4 +const watchify = require('watchify');
5 +const errorify = require('errorify');
6 +const del = require('del');
7 +const tsify = require('tsify');
8 +const source = require('vinyl-source-stream');
9 +const buffer = require('vinyl-buffer');
10 +const runSequence = require('run-sequence');
11 +const uglify = require('gulp-uglify');
12 +
13 +gulp.task('clean', () => {
14 + return del('./built/**/*')
15 +});
16 +
17 +gulp.task('prod', () => {
18 + browserify({
19 + basedir: '.',
20 + debug: true,
21 + entries: ['src'],
22 + cache: {},
23 + packageCache: {}
24 + })
25 + .plugin(tsify)
26 + .bundle()
27 + .pipe(source('bundle.js'))
28 + .pipe(buffer())
29 + .pipe(uglify())
30 + .pipe(gulp.dest('built'));
31 +});
32 +
33 +gulp.task('dev', () => {
34 + browserify({
35 + basedir: '.',
36 + debug: true,
37 + entries: ['src'],
38 + cache: {},
39 + packageCache: {}
40 + })
41 + .plugin(tsify)
42 + .plugin(watchify)
43 + .plugin(errorify)
44 + .bundle()
45 + .pipe(source('bundle.js'))
46 + .pipe(gulp.dest('built'));
47 +});
48 +
49 +gulp.task('default', (done) => {
50 + runSequence('clean', 'dev', () => {
51 + console.log('Watching...')
52 + gulp.watch(['src/**/*.ts'],
53 + ['dev']);
54 + });
55 +});
56 +
57 +gulp.task('package', (done) => {
58 + runSequence('clean', 'prod', () => {
59 + console.log('Watching...')
60 + gulp.watch(['src/**/*.ts'],
61 + ['prod']);
62 + });
63 +});
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
6 </head> 6 </head>
7 <body> 7 <body>
8 <div id="App"></div> 8 <div id="App"></div>
9 - <script>var exports = {};</script> 9 + <script type="module" src="build/dist/main.js" ></script>
10 - <script src="build/src/index.js" ></script>
11 </body> 10 </body>
12 </html> 11 </html>
...\ No newline at end of file ...\ No newline at end of file
......
This diff could not be displayed because it is too large.
...@@ -18,12 +18,17 @@ ...@@ -18,12 +18,17 @@
18 "prepare": "npm.cmd run compile", 18 "prepare": "npm.cmd run compile",
19 "pretest": "npm.cmd run compile", 19 "pretest": "npm.cmd run compile",
20 "posttest": "npm.cmd run lint", 20 "posttest": "npm.cmd run lint",
21 - "build": "tsc --build", 21 + "build": "webpack --watch",
22 - "dev": "tsc -w" 22 + "dev": "tsc -w",
23 + "start": "http-server ./",
24 + "hot": "webpack serve --open"
23 }, 25 },
24 "devDependencies": { 26 "devDependencies": {
25 "@types/node": "^14.11.2", 27 "@types/node": "^14.11.2",
26 "gts": "^3.1.0", 28 "gts": "^3.1.0",
27 - "typescript": "^4.0.3" 29 + "typescript": "^4.0.3",
30 + "webpack": "^5.24.3",
31 + "webpack-cli": "^4.5.0",
32 + "webpack-dev-server": "^3.11.2"
28 } 33 }
29 } 34 }
......
1 +export const Bye = () => console.log('Bye!');
1 -const hi = 'hi'; 1 +import {Bye} from './Bye';
2 2
3 -export const hi1 = () => { 3 +const hi = 'hello?';
4 +
5 +const hi1 = () => {
4 console.log(hi); 6 console.log(hi);
7 + Bye();
5 }; 8 };
6 9
7 hi1(); 10 hi1();
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -2,10 +2,14 @@ ...@@ -2,10 +2,14 @@
2 "extends": "./node_modules/gts/tsconfig-google.json", 2 "extends": "./node_modules/gts/tsconfig-google.json",
3 "compilerOptions": { 3 "compilerOptions": {
4 "rootDir": ".", 4 "rootDir": ".",
5 - "outDir": "build" 5 + "outDir": "build",
6 + "target": "es6",
7 + "module": "commonjs",
8 + "strict": true,
9 + "removeComments": true,
10 + "esModuleInterop": true
6 }, 11 },
7 "include": [ 12 "include": [
8 - "src/**/*.ts", 13 + "src/**/*.ts"
9 - "test/**/*.ts"
10 ] 14 ]
11 } 15 }
......
1 +const path = require('path')
2 +
3 +module.exports = {
4 + mode : 'development',
5 + entry : {
6 + main : './build/src/index.js'
7 + },
8 + output : {
9 + publicPath: '/app/build/dist',
10 + path: path.resolve('./build/dist'),
11 + filename: '[name].js',
12 + },
13 + devServer : {
14 + port : 3000,
15 + hot: true,
16 + contentBase: ['./build','./src'],
17 + inline: true,
18 + watchOptions: {
19 + poll: true
20 + }
21 + }
22 +}
...\ No newline at end of file ...\ No newline at end of file