diff --git a/client/config/webpack.config.dev.js b/client/config/webpack.config.dev.js index 97347dc8..ef42fa5c 100644 --- a/client/config/webpack.config.dev.js +++ b/client/config/webpack.config.dev.js @@ -81,28 +81,6 @@ module.exports = { use: ['source-map-loader'], enforce: 'pre', }, - { - enforce: 'pre', - test: /\.svg$/, - issuer: /\.(ts|js)x?$/, - use: [ - { - loader: 'babel-loader', - options: { - babelrc: true, - }, - }, - { - loader: 'svg-sprite-loader', - options: { - runtimeGenerator: require.resolve('../scripts/svg-react-component-generator'), - runtimeOptions: { - iconModule: require.resolve('../src/javascript/components/general/Icon.tsx'), - }, - }, - }, - ], - }, { test: /\.md$/, loader: 'frontmatter-markdown-loader', diff --git a/client/config/webpack.config.prod.js b/client/config/webpack.config.prod.js index 79d3857f..7b5a4650 100644 --- a/client/config/webpack.config.prod.js +++ b/client/config/webpack.config.prod.js @@ -77,27 +77,6 @@ module.exports = { use: ['source-map-loader'], enforce: 'pre', }, - { - test: /\.svg$/, - issuer: /\.(ts|js)x?$/, - use: [ - { - loader: 'babel-loader', - options: { - babelrc: true, - }, - }, - { - loader: 'svg-sprite-loader', - options: { - runtimeGenerator: require.resolve('../scripts/svg-react-component-generator'), - runtimeOptions: { - iconModule: require.resolve('../src/javascript/components/general/Icon.tsx'), - }, - }, - }, - ], - }, { test: /\.md$/, loader: 'frontmatter-markdown-loader', diff --git a/client/scripts/svg-react-component-generator.js b/client/scripts/svg-react-component-generator.js deleted file mode 100644 index cf9164ea..00000000 --- a/client/scripts/svg-react-component-generator.js +++ /dev/null @@ -1,56 +0,0 @@ -const path = require('path'); -const pascalCase = require('pascal-case'); -const {stringifyRequest} = require('loader-utils'); - -const stringifiedRegexp = /^'|".*'|"$/; - -const stringify = (content) => { - if (typeof content === 'string' && stringifiedRegexp.test(content)) { - return content; - } - return JSON.stringify(content, null, 2); -}; - -const stringifySymbol = (symbol) => - stringify({ - id: symbol.id, - use: symbol.useId, - viewBox: symbol.viewBox, - content: symbol.render(), - }); - -const runtimeGenerator = ({symbol, config, loaderContext}) => { - const {spriteModule, symbolModule, runtimeOptions} = config; - // eslint-disable-next-line no-underscore-dangle - const compilerContext = loaderContext._compiler.context; - - const iconModulePath = path.resolve(compilerContext, runtimeOptions.iconModule); - const iconModuleRequest = stringify(path.relative(path.dirname(symbol.request.file), iconModulePath)); - - const spriteRequest = stringifyRequest( - {context: loaderContext.context}, - path.resolve(loaderContext.context, spriteModule), - ); - const symbolRequest = stringifyRequest( - {context: loaderContext.context}, - path.resolve(loaderContext.context, symbolModule), - ); - const parentComponentDisplayName = 'SpriteSymbolComponent'; - const displayName = `${pascalCase(symbol.id)}_${parentComponentDisplayName}`; - - return ` - import * as React from 'react'; - import SpriteSymbol from ${symbolRequest}; - import sprite from ${spriteRequest}; - import ${parentComponentDisplayName} from ${iconModuleRequest}; - - const symbol = new SpriteSymbol(${stringifySymbol(symbol)}); - sprite.add(symbol); - const ${displayName} = props => { - return <${parentComponentDisplayName} glyph="${symbol.id}" {...props} />; - }; - export default ${displayName}; - `; -}; - -module.exports = runtimeGenerator; diff --git a/client/src/javascript/components/general/Icon.scss b/client/src/javascript/components/general/Icon.scss deleted file mode 100644 index ae3518af..00000000 --- a/client/src/javascript/components/general/Icon.scss +++ /dev/null @@ -1,17 +0,0 @@ -.icon { - display: block; -} - -.sizeSmall { - height: 12px; - width: 12px; -} - -.sizeMedium { - height: 16px; - width: 16px; -} - -.fillCurrentColor { - fill: currentColor; -} diff --git a/client/src/javascript/components/general/Icon.scss.d.ts b/client/src/javascript/components/general/Icon.scss.d.ts deleted file mode 100644 index 51e28171..00000000 --- a/client/src/javascript/components/general/Icon.scss.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare const styles: { - readonly icon: string; - readonly sizeSmall: string; - readonly sizeMedium: string; - readonly fillCurrentColor: string; -}; -export = styles; diff --git a/client/src/javascript/components/general/Icon.tsx b/client/src/javascript/components/general/Icon.tsx deleted file mode 100644 index b64c213f..00000000 --- a/client/src/javascript/components/general/Icon.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import classnames from 'classnames'; -import * as React from 'react'; -import * as styles from './Icon.scss'; - -enum Fills { - NONE, - CURRENT_COLOR, -} - -enum Sizes { - SMALL, - MEDIUM, -} - -interface Props { - className?: string; - fill: Fills; - glyph: string; - size: Sizes; -} - -export default class Icon extends React.PureComponent { - public static defaultProps = { - fill: Fills.CURRENT_COLOR, - size: Sizes.MEDIUM, - }; - - public static Fills = Fills; - - public static Sizes = Sizes; - - public render(): React.ReactNode { - const {className, fill, glyph, size, ...restProps} = this.props; - - return ( - - - - ); - } -} diff --git a/custom.d.ts b/custom.d.ts deleted file mode 100644 index 091d25e2..00000000 --- a/custom.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module '*.svg' { - const content: any; - export default content; -} diff --git a/package-lock.json b/package-lock.json index 3823b7c7..68aa11f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -119,7 +119,6 @@ "node-sass": "^5.0.0", "overlayscrollbars": "^1.13.0", "overlayscrollbars-react": "^0.2.2", - "pascal-case": "^3.1.1", "passport": "^0.4.1", "passport-jwt": "^4.0.0", "postcss": "^8.1.7", diff --git a/package.json b/package.json index 419fd822..a3e1ea42 100644 --- a/package.json +++ b/package.json @@ -159,7 +159,6 @@ "node-sass": "^5.0.0", "overlayscrollbars": "^1.13.0", "overlayscrollbars-react": "^0.2.2", - "pascal-case": "^3.1.1", "passport": "^0.4.1", "passport-jwt": "^4.0.0", "postcss": "^8.1.7", diff --git a/tsconfig.json b/tsconfig.json index a2cb36dd..cc86f281 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,6 +18,6 @@ "@shared/*": ["shared/*"] } }, - "include": ["./client/**/*.ts", "./client/**/*.tsx", "./server/**/*.ts", "./server/**/*.tsx", "./custom.d.ts"], + "include": ["./client/**/*.ts", "./client/**/*.tsx", "./server/**/*.ts", "./server/**/*.tsx"], "exclude": ["node_modules"] }