From 84556e09fe5316f44fa1c0332cdd12c2606907a4 Mon Sep 17 00:00:00 2001 From: danbulant Date: Sat, 15 Feb 2020 17:31:22 +0100 Subject: [PATCH] Configure webpack + typescript --- client/tsconfig.json | 11 ++++++++ client/webpack.config.js | 56 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 client/tsconfig.json create mode 100644 client/webpack.config.js diff --git a/client/tsconfig.json b/client/tsconfig.json new file mode 100644 index 0000000..a927614 --- /dev/null +++ b/client/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "outDir": "./build/", + "noImplicitAny": true, + "sourceMap": true, + "module": "es6", + "target": "es5", + "jsx": "react", + "allowJs": true + } +} \ No newline at end of file diff --git a/client/webpack.config.js b/client/webpack.config.js new file mode 100644 index 0000000..ca5087c --- /dev/null +++ b/client/webpack.config.js @@ -0,0 +1,56 @@ +const CopyWebpackPlugin = require('copy-webpack-plugin'); +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + devtool: 'inline-source-map', + module: { + rules: [ + // TYPESCRIPT + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/, + }, + // STYLESHEETS + { + test: /\.css$/, + use: [ + 'style-loader', + 'css-loader', + ], + }, + // IMAGES + { + test: /\.(png|svg|jpg|gif)$/, + use: [ + 'file-loader', + ], + }, + // FONTS + { + test: /\.(woff|woff2|eot|ttf|otf)$/, + use: [ + 'file-loader', + ], + }, + ], + }, + resolve: { + extensions: ['.tsx', '.ts', '.js'], + }, + output: { + filename: 'main.js', + path: path.resolve(__dirname, 'build'), + }, + + plugins: [ + new CopyWebpackPlugin([ + { + //Note:- No wildcard is specified hence will copy all files and folders + from: 'static', //Will resolve to RepoDir/src/assets + to: '' //Copies all files from above dest to dist/assets + } + ]) + ] +}; \ No newline at end of file