diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..ac9f9f4 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "tabWidth": 2, + "useTabs": false, + "semi": true, + "singleQuote": true, + "arrowParens": "always" +} diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js index 711b403..90464e1 100755 --- a/config/webpack.config.dev.js +++ b/config/webpack.config.dev.js @@ -15,13 +15,12 @@ const HtmlWebpackPlugin = require('html-webpack-plugin'); const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin'); const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin'); -// const eslintFormatter = require('react-dev-utils/eslintFormatter'); const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin'); const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent'); const getClientEnvironment = require('./env'); const paths = require('./paths'); +const shared = require('./webpack.shared'); -// const HardSourceWebpackPlugin = require('hard-source-webpack-plugin'); const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); @@ -35,7 +34,6 @@ const publicUrl = ''; // Get environment variables to inject into our app. const env = getClientEnvironment(publicUrl); - // style files regexes const cssRegex = /\.css$/; const cssModuleRegex = /\.module\.css$/; @@ -48,7 +46,7 @@ const getStyleLoaders = (cssOptions, preProcessor) => { require.resolve('style-loader'), { loader: require.resolve('css-loader'), - options: cssOptions, + options: cssOptions }, { // Options for PostCSS as we reference these options twice @@ -62,11 +60,11 @@ const getStyleLoaders = (cssOptions, preProcessor) => { plugins: () => [ require('postcss-flexbugs-fixes'), autoprefixer({ - flexbox: 'no-2009', - }), - ], - }, - }, + flexbox: 'no-2009' + }) + ] + } + } ]; if (preProcessor) { loaders.push(require.resolve(preProcessor)); @@ -100,7 +98,7 @@ module.exports = { // require.resolve('webpack/hot/dev-server'), require.resolve('react-dev-utils/webpackHotDevClient'), // Finally, this is your app's code: - paths.appIndexJs, + paths.appIndexJs // We include the app code last so that if there is a runtime error during // initialization, it doesn't blow up the WebpackDevServer client, and // changing JS code would still trigger a refresh. @@ -117,8 +115,8 @@ module.exports = { // This is the URL that app is served from. We use "/" in development. publicPath: publicPath, // Point sourcemap entries to original disk location (format as URL on Windows) - devtoolModuleFilenameTemplate: info => - path.resolve(info.absoluteResourcePath).replace(/\\/g, '/'), + devtoolModuleFilenameTemplate: (info) => + path.resolve(info.absoluteResourcePath).replace(/\\/g, '/') }, resolve: { // This allows you to set a fallback for where Webpack should look for modules. @@ -160,7 +158,7 @@ module.exports = { // @remove-on-eject-end // Support React Native Web // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/ - 'react-native': 'react-native-web', + 'react-native': 'react-native-web' }, plugins: [ // Prevents users from importing files from outside of src/ (or node_modules/). @@ -169,8 +167,8 @@ module.exports = { // please link the files into your node_modules/ and let module-resolution kick in. // Make sure your source files are compiled, as they will not be processed in any way. new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]), - new TsconfigPathsPlugin({ configFile: paths.appTsConfig }), - ], + new TsconfigPathsPlugin({ configFile: paths.appTsConfig }) + ] }, optimization: { // Automatically split vendor and commons @@ -198,8 +196,8 @@ module.exports = { loader: require.resolve('url-loader'), options: { limit: 10000, - name: 'static/media/[name].[hash:8].[ext]', - }, + name: 'static/media/[name].[hash:8].[ext]' + } }, { test: /\.(js|jsx|mjs)$/, @@ -217,18 +215,16 @@ module.exports = { // @remove-on-eject-end presets: [require.resolve('@babel/preset-react')], plugins: [ - [ - require.resolve('babel-plugin-named-asset-import'), - ], + [require.resolve('babel-plugin-named-asset-import')] ], // This is a feature of `babel-loader` for webpack (not Babel itself). // It enables caching results in ./node_modules/.cache/babel-loader/ // directory for faster rebuilds. cacheDirectory: true, - highlightCode: true, - }, - }, - ], + highlightCode: true + } + } + ] }, // Process any JS outside of the app with Babel. // Unlike the application JS, we only compile the standard ES features. @@ -243,42 +239,15 @@ module.exports = { options: { babelrc: false, compact: false, - presets: [ - require.resolve('@babel/preset-react'), - ], + presets: [require.resolve('@babel/preset-react')], cacheDirectory: true, - highlightCode: true, - }, - }, - ], - }, - // Compile .ts and .tsx - { - test: /\.tsx?$/, - include: paths.srcPaths, - exclude: /[\\/]node_modules[\\/]/, - use: [ - { - loader: require.resolve('awesome-typescript-loader'), - options: { - transpileOnly: true, - reportFiles: [ - paths.appSrc + '/**/*.{ts,tsx}' - ], - forceIsolatedModules: true, - useBabel: true, - babelOptions: { - babelrc: false, - compact: false, - presets: [ - require.resolve('@babel/preset-react'), - ], - }, - babelCore: require.resolve('@babel/core'), - }, - }, + highlightCode: true + } + } ] }, + // Compile .ts and .tsx + shared.typeScriptLoader, // "postcss" loader applies autoprefixer to our CSS. // "css" loader resolves paths in CSS and adds assets as dependencies. // "style" loader turns CSS into JS modules that inject