Improve TSLint rules and fix issues
This commit is contained in:
+28
-28
@@ -1,60 +1,60 @@
|
|||||||
// shared config (dev and prod)
|
// Shared config (dev and prod)
|
||||||
const {resolve} = require('path');
|
const {resolve} = require("path");
|
||||||
const {CheckerPlugin} = require('awesome-typescript-loader');
|
const {CheckerPlugin} = require("awesome-typescript-loader");
|
||||||
const StyleLintPlugin = require('stylelint-webpack-plugin');
|
const StyleLintPlugin = require("stylelint-webpack-plugin");
|
||||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
||||||
const Dotenv = require('dotenv-webpack');
|
const Dotenv = require("dotenv-webpack");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.ts', '.tsx', '.js', '.jsx'],
|
extensions: [".ts", ".tsx", ".js", ".jsx"]
|
||||||
},
|
},
|
||||||
context: resolve(__dirname, '../../src'),
|
context: resolve(__dirname, "../../src"),
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
use: ['babel-loader', 'source-map-loader'],
|
use: ["babel-loader", "source-map-loader"],
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.tsx?$/,
|
test: /\.tsx?$/,
|
||||||
use: ['babel-loader', 'awesome-typescript-loader'],
|
use: ["babel-loader", "awesome-typescript-loader"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.css$/,
|
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$/,
|
test: /\.scss$/,
|
||||||
loaders: [
|
loaders: [
|
||||||
'style-loader',
|
"style-loader",
|
||||||
{ loader: 'css-loader', options: { importLoaders: 1 } },
|
{loader: "css-loader", options: {importLoaders: 1}},
|
||||||
'postcss-loader',
|
"postcss-loader",
|
||||||
'sass-loader',
|
"sass-loader"
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.(jpe?g|png|gif|svg)$/i,
|
test: /\.(jpe?g|png|gif|svg)$/i,
|
||||||
loaders: [
|
loaders: [
|
||||||
'file-loader?hash=sha512&digest=hex&name=img/[hash].[ext]',
|
"file-loader?hash=sha512&digest=hex&name=img/[hash].[ext]",
|
||||||
'image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false',
|
"image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false"
|
||||||
],
|
]
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new CheckerPlugin(),
|
new CheckerPlugin(),
|
||||||
new StyleLintPlugin(),
|
new StyleLintPlugin(),
|
||||||
new HtmlWebpackPlugin({template: 'index.html.ejs',}),
|
new HtmlWebpackPlugin({template: "index.html.ejs"}),
|
||||||
new Dotenv({
|
new Dotenv({
|
||||||
path: './.env.sample',
|
path: "./.env.sample"
|
||||||
}),
|
}),
|
||||||
new Dotenv({
|
new Dotenv({
|
||||||
path: './.env',
|
path: "./.env"
|
||||||
}),
|
})
|
||||||
],
|
],
|
||||||
performance: {
|
performance: {
|
||||||
hints: false,
|
hints: false
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+17
-17
@@ -1,26 +1,26 @@
|
|||||||
// development config
|
// Development config
|
||||||
const merge = require('webpack-merge');
|
const merge = require("webpack-merge");
|
||||||
const webpack = require('webpack');
|
const webpack = require("webpack");
|
||||||
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
|
const FaviconsWebpackPlugin = require("favicons-webpack-plugin");
|
||||||
|
|
||||||
const commonConfig = require('./common');
|
const commonConfig = require("./common");
|
||||||
|
|
||||||
module.exports = merge(commonConfig, {
|
module.exports = merge(commonConfig, {
|
||||||
mode: 'development',
|
mode: "development",
|
||||||
entry: [
|
entry: [
|
||||||
'react-hot-loader/patch', // activate HMR for React
|
"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-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
|
"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
|
"./index.tsx" // The entry point of our app
|
||||||
],
|
],
|
||||||
devServer: {
|
devServer: {
|
||||||
hot: true, // enable HMR on the server
|
hot: true, // Enable HMR on the server
|
||||||
historyApiFallback: true,
|
historyApiFallback: true
|
||||||
},
|
},
|
||||||
devtool: 'cheap-module-eval-source-map',
|
devtool: "cheap-module-eval-source-map",
|
||||||
plugins: [
|
plugins: [
|
||||||
new FaviconsWebpackPlugin({
|
new FaviconsWebpackPlugin({
|
||||||
logo: './assets/img/favicon.png',
|
logo: "./assets/img/favicon.png",
|
||||||
icons: {
|
icons: {
|
||||||
android: false,
|
android: false,
|
||||||
appleIcon: false,
|
appleIcon: false,
|
||||||
@@ -34,7 +34,7 @@ module.exports = merge(commonConfig, {
|
|||||||
windows: false
|
windows: false
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
new webpack.HotModuleReplacementPlugin(), // enable HMR globally
|
new webpack.HotModuleReplacementPlugin(), // Enable HMR globally
|
||||||
new webpack.NamedModulesPlugin(), // prints more readable module names in the browser console on HMR updates
|
new webpack.NamedModulesPlugin() // Prints more readable module names in the browser console on HMR updates
|
||||||
],
|
]
|
||||||
});
|
});
|
||||||
|
|||||||
+18
-17
@@ -1,30 +1,31 @@
|
|||||||
// production config
|
// Production config
|
||||||
const merge = require('webpack-merge');
|
const path = require("path");
|
||||||
const path = require('path')
|
const merge = require("webpack-merge");
|
||||||
|
|
||||||
const resolve = path.resolve;
|
const resolve = path.resolve;
|
||||||
const DynamicCdnWebpackPlugin = require('dynamic-cdn-webpack-plugin');
|
const DynamicCdnWebpackPlugin = require("dynamic-cdn-webpack-plugin");
|
||||||
const PrerenderSPAPlugin = require('prerender-spa-plugin');
|
const PrerenderSPAPlugin = require("prerender-spa-plugin");
|
||||||
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
|
const FaviconsWebpackPlugin = require("favicons-webpack-plugin");
|
||||||
|
|
||||||
/* NOTE: This is a list of all routes that are prerendered for production use.
|
/* 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.,
|
Please list all routes that contain search engine accessible content, i.e.,
|
||||||
stuff that you would like to find with a Google Search. */
|
stuff that you would like to find with a Google Search. */
|
||||||
const PRERENDERED_ROUTES = ["/", "/404"];
|
const PRERENDERED_ROUTES = ["/", "/404"];
|
||||||
|
|
||||||
const commonConfig = require('./common');
|
const commonConfig = require("./common");
|
||||||
|
|
||||||
module.exports = merge(commonConfig, {
|
module.exports = merge(commonConfig, {
|
||||||
mode: 'production',
|
mode: "production",
|
||||||
entry: './index.tsx',
|
entry: "./index.tsx",
|
||||||
output: {
|
output: {
|
||||||
filename: 'js/bundle.[hash].min.js',
|
filename: "js/bundle.[hash].min.js",
|
||||||
path: resolve(__dirname, '../../dist'),
|
path: resolve(__dirname, "../../dist"),
|
||||||
publicPath: '/',
|
publicPath: "/"
|
||||||
},
|
},
|
||||||
devtool: 'source-map',
|
devtool: "source-map",
|
||||||
plugins: [
|
plugins: [
|
||||||
new FaviconsWebpackPlugin({
|
new FaviconsWebpackPlugin({
|
||||||
logo: './assets/img/favicon.png',
|
logo: "./assets/img/favicon.png",
|
||||||
icons: {
|
icons: {
|
||||||
android: true,
|
android: true,
|
||||||
appleIcon: true,
|
appleIcon: true,
|
||||||
@@ -41,9 +42,9 @@ module.exports = merge(commonConfig, {
|
|||||||
new DynamicCdnWebpackPlugin(),
|
new DynamicCdnWebpackPlugin(),
|
||||||
new PrerenderSPAPlugin({
|
new PrerenderSPAPlugin({
|
||||||
// Required - The path to the webpack-outputted app to prerender.
|
// Required - The path to the webpack-outputted app to prerender.
|
||||||
staticDir: resolve(__dirname, '../../dist'),
|
staticDir: resolve(__dirname, "../../dist"),
|
||||||
// Required - Routes to render.
|
// Required - Routes to render.
|
||||||
routes: PRERENDERED_ROUTES,
|
routes: PRERENDERED_ROUTES
|
||||||
})
|
})
|
||||||
],
|
]
|
||||||
});
|
});
|
||||||
|
|||||||
+2
-1
@@ -19,7 +19,8 @@
|
|||||||
"build": "npm run clean-dist && webpack -p --config=configs/webpack/prod.js",
|
"build": "npm run clean-dist && webpack -p --config=configs/webpack/prod.js",
|
||||||
"clean-dist": "rm -f -r -d dist",
|
"clean-dist": "rm -f -r -d dist",
|
||||||
"lint": "npm run lint:ts && npm run lint:sass",
|
"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",
|
"lint:sass": "stylelint ./src/**/**/*.scss ./src/**/*.scss ./src/*.scss",
|
||||||
"start": "npm run start-dev",
|
"start": "npm run start-dev",
|
||||||
"start-dev": "webpack-dev-server --config=configs/webpack/dev.js",
|
"start-dev": "webpack-dev-server --config=configs/webpack/dev.js",
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
import Button from "./Button";
|
import Button from "./Button";
|
||||||
export default Button;
|
export default Button;
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
import FrontPage from "./FrontPage";
|
import FrontPage from "./FrontPage";
|
||||||
export default FrontPage;
|
export default FrontPage;
|
||||||
|
|||||||
+13
-13
@@ -1,15 +1,15 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "./dist/",
|
"outDir": "./dist/",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"jsx": "react",
|
"jsx": "react",
|
||||||
"lib": ["es5", "es6", "dom"],
|
"lib": ["es5", "es6", "dom"],
|
||||||
"experimentalDecorators": true
|
"experimentalDecorators": true
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"./src/**/*"
|
"./src/**/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
true,
|
true,
|
||||||
"check-space"
|
"check-space"
|
||||||
],
|
],
|
||||||
|
"eofline": true,
|
||||||
"indent": [
|
"indent": [
|
||||||
true,
|
true,
|
||||||
"spaces",
|
"spaces",
|
||||||
@@ -50,6 +51,7 @@
|
|||||||
true,
|
true,
|
||||||
"check-space"
|
"check-space"
|
||||||
],
|
],
|
||||||
|
"eofline": true,
|
||||||
"indent": [
|
"indent": [
|
||||||
true,
|
true,
|
||||||
"spaces",
|
"spaces",
|
||||||
|
|||||||
Reference in New Issue
Block a user