diff --git a/configs/webpack/common.js b/configs/webpack/common.js index bdeaf8f..508de03 100644 --- a/configs/webpack/common.js +++ b/configs/webpack/common.js @@ -1,60 +1,60 @@ -// shared config (dev and prod) -const {resolve} = require('path'); -const {CheckerPlugin} = require('awesome-typescript-loader'); -const StyleLintPlugin = require('stylelint-webpack-plugin'); -const HtmlWebpackPlugin = require('html-webpack-plugin'); -const Dotenv = require('dotenv-webpack'); +// Shared config (dev and prod) +const {resolve} = require("path"); +const {CheckerPlugin} = require("awesome-typescript-loader"); +const StyleLintPlugin = require("stylelint-webpack-plugin"); +const HtmlWebpackPlugin = require("html-webpack-plugin"); +const Dotenv = require("dotenv-webpack"); module.exports = { resolve: { - extensions: ['.ts', '.tsx', '.js', '.jsx'], + extensions: [".ts", ".tsx", ".js", ".jsx"] }, - context: resolve(__dirname, '../../src'), + context: resolve(__dirname, "../../src"), module: { rules: [ { test: /\.js$/, - use: ['babel-loader', 'source-map-loader'], - exclude: /node_modules/, + use: ["babel-loader", "source-map-loader"], + exclude: /node_modules/ }, { test: /\.tsx?$/, - use: ['babel-loader', 'awesome-typescript-loader'], + use: ["babel-loader", "awesome-typescript-loader"] }, { test: /\.css$/, - use: ['style-loader', { loader: 'css-loader', options: { importLoaders: 1 } }, 'postcss-loader',], + use: ["style-loader", {loader: "css-loader", options: {importLoaders: 1}}, "postcss-loader"] }, { test: /\.scss$/, loaders: [ - 'style-loader', - { loader: 'css-loader', options: { importLoaders: 1 } }, - 'postcss-loader', - 'sass-loader', - ], + "style-loader", + {loader: "css-loader", options: {importLoaders: 1}}, + "postcss-loader", + "sass-loader" + ] }, { test: /\.(jpe?g|png|gif|svg)$/i, loaders: [ - 'file-loader?hash=sha512&digest=hex&name=img/[hash].[ext]', - 'image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false', - ], - }, - ], + "file-loader?hash=sha512&digest=hex&name=img/[hash].[ext]", + "image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false" + ] + } + ] }, plugins: [ new CheckerPlugin(), new StyleLintPlugin(), - new HtmlWebpackPlugin({template: 'index.html.ejs',}), + new HtmlWebpackPlugin({template: "index.html.ejs"}), new Dotenv({ - path: './.env.sample', + path: "./.env.sample" }), new Dotenv({ - path: './.env', - }), + path: "./.env" + }) ], performance: { - hints: false, - }, + hints: false + } }; diff --git a/configs/webpack/dev.js b/configs/webpack/dev.js index d152d7c..4977852 100644 --- a/configs/webpack/dev.js +++ b/configs/webpack/dev.js @@ -1,26 +1,26 @@ -// development config -const merge = require('webpack-merge'); -const webpack = require('webpack'); -const FaviconsWebpackPlugin = require('favicons-webpack-plugin'); +// Development config +const merge = require("webpack-merge"); +const webpack = require("webpack"); +const FaviconsWebpackPlugin = require("favicons-webpack-plugin"); -const commonConfig = require('./common'); +const commonConfig = require("./common"); module.exports = merge(commonConfig, { - mode: 'development', + mode: "development", entry: [ - 'react-hot-loader/patch', // activate HMR for React - 'webpack-dev-server/client?http://localhost:8080',// bundle the client for webpack-dev-server and connect to the provided endpoint - 'webpack/hot/only-dev-server', // bundle the client for hot reloading, only- means to only hot reload for successful updates - './index.tsx' // the entry point of our app + "react-hot-loader/patch", // Activate HMR for React + "webpack-dev-server/client?http://localhost:8080", // Bundle the client for webpack-dev-server and connect to the provided endpoint + "webpack/hot/only-dev-server", // Bundle the client for hot reloading, only- means to only hot reload for successful updates + "./index.tsx" // The entry point of our app ], devServer: { - hot: true, // enable HMR on the server - historyApiFallback: true, + hot: true, // Enable HMR on the server + historyApiFallback: true }, - devtool: 'cheap-module-eval-source-map', + devtool: "cheap-module-eval-source-map", plugins: [ new FaviconsWebpackPlugin({ - logo: './assets/img/favicon.png', + logo: "./assets/img/favicon.png", icons: { android: false, appleIcon: false, @@ -34,7 +34,7 @@ module.exports = merge(commonConfig, { windows: false } }), - new webpack.HotModuleReplacementPlugin(), // enable HMR globally - new webpack.NamedModulesPlugin(), // prints more readable module names in the browser console on HMR updates - ], + new webpack.HotModuleReplacementPlugin(), // Enable HMR globally + new webpack.NamedModulesPlugin() // Prints more readable module names in the browser console on HMR updates + ] }); diff --git a/configs/webpack/prod.js b/configs/webpack/prod.js index b26a0cb..89a7b67 100644 --- a/configs/webpack/prod.js +++ b/configs/webpack/prod.js @@ -1,30 +1,31 @@ -// production config -const merge = require('webpack-merge'); -const path = require('path') +// Production config +const path = require("path"); +const merge = require("webpack-merge"); + const resolve = path.resolve; -const DynamicCdnWebpackPlugin = require('dynamic-cdn-webpack-plugin'); -const PrerenderSPAPlugin = require('prerender-spa-plugin'); -const FaviconsWebpackPlugin = require('favicons-webpack-plugin'); +const DynamicCdnWebpackPlugin = require("dynamic-cdn-webpack-plugin"); +const PrerenderSPAPlugin = require("prerender-spa-plugin"); +const FaviconsWebpackPlugin = require("favicons-webpack-plugin"); /* NOTE: This is a list of all routes that are prerendered for production use. Please list all routes that contain search engine accessible content, i.e., stuff that you would like to find with a Google Search. */ const PRERENDERED_ROUTES = ["/", "/404"]; -const commonConfig = require('./common'); +const commonConfig = require("./common"); module.exports = merge(commonConfig, { - mode: 'production', - entry: './index.tsx', + mode: "production", + entry: "./index.tsx", output: { - filename: 'js/bundle.[hash].min.js', - path: resolve(__dirname, '../../dist'), - publicPath: '/', + filename: "js/bundle.[hash].min.js", + path: resolve(__dirname, "../../dist"), + publicPath: "/" }, - devtool: 'source-map', + devtool: "source-map", plugins: [ new FaviconsWebpackPlugin({ - logo: './assets/img/favicon.png', + logo: "./assets/img/favicon.png", icons: { android: true, appleIcon: true, @@ -41,9 +42,9 @@ module.exports = merge(commonConfig, { new DynamicCdnWebpackPlugin(), new PrerenderSPAPlugin({ // Required - The path to the webpack-outputted app to prerender. - staticDir: resolve(__dirname, '../../dist'), + staticDir: resolve(__dirname, "../../dist"), // Required - Routes to render. - routes: PRERENDERED_ROUTES, + routes: PRERENDERED_ROUTES }) - ], + ] }); diff --git a/package.json b/package.json index 5f14f87..b416f0d 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "build": "npm run clean-dist && webpack -p --config=configs/webpack/prod.js", "clean-dist": "rm -f -r -d dist", "lint": "npm run lint:ts && npm run lint:sass", - "lint:ts": "tslint './src/**/**/*.ts*' './src/**/*.ts*' './src/*.ts*' './*.ts*' --format stylish --force", + "lint:ts": "tslint -p tsconfig.json --format stylish --exclude node_modules", + "lint:ts:fix": "tslint -p tsconfig.json --format stylish --exclude node_modules --fix", "lint:sass": "stylelint ./src/**/**/*.scss ./src/**/*.scss ./src/*.scss", "start": "npm run start-dev", "start-dev": "webpack-dev-server --config=configs/webpack/dev.js", diff --git a/src/components/Button/index.ts b/src/components/Button/index.ts index 846ff85..317a298 100644 --- a/src/components/Button/index.ts +++ b/src/components/Button/index.ts @@ -1,2 +1,2 @@ import Button from "./Button"; -export default Button; \ No newline at end of file +export default Button; diff --git a/src/pages/FrontPage/index.ts b/src/pages/FrontPage/index.ts index ca980cd..23d37ad 100644 --- a/src/pages/FrontPage/index.ts +++ b/src/pages/FrontPage/index.ts @@ -1,2 +1,2 @@ import FrontPage from "./FrontPage"; -export default FrontPage; \ No newline at end of file +export default FrontPage; diff --git a/tsconfig.json b/tsconfig.json index 665fd83..682547f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,15 +1,15 @@ { - "compilerOptions": { - "outDir": "./dist/", - "sourceMap": true, - "noImplicitAny": false, - "module": "commonjs", - "target": "es5", - "jsx": "react", - "lib": ["es5", "es6", "dom"], - "experimentalDecorators": true - }, - "include": [ - "./src/**/*" - ] + "compilerOptions": { + "outDir": "./dist/", + "sourceMap": true, + "noImplicitAny": false, + "module": "commonjs", + "target": "es5", + "jsx": "react", + "lib": ["es5", "es6", "dom"], + "experimentalDecorators": true + }, + "include": [ + "./src/**/*" + ] } diff --git a/tslint.json b/tslint.json index b02a2c8..fd2e241 100644 --- a/tslint.json +++ b/tslint.json @@ -5,6 +5,7 @@ true, "check-space" ], + "eofline": true, "indent": [ true, "spaces", @@ -50,6 +51,7 @@ true, "check-space" ], + "eofline": true, "indent": [ true, "spaces",