@@ -2,19 +2,74 @@ import React from 'react';
2
2
import ReactDOM from 'react-dom' ;
3
3
import styled from 'styled-components' ;
4
4
5
+ import { Light as SyntaxHighlighter } from 'react-syntax-highlighter' ;
6
+ import js from 'react-syntax-highlighter/dist/languages/hljs/javascript' ;
7
+ import railscasts from 'react-syntax-highlighter/dist/styles/hljs/railscasts' ;
8
+
9
+ SyntaxHighlighter . registerLanguage ( 'javascript' , js ) ;
10
+
5
11
const Title = styled . h1 `
6
12
font-family: sans-serif;
7
13
padding: 2em;
8
14
background: papayawhip;
9
- font-size: 4em ;
15
+ font-size: 2em ;
10
16
text-align: center;
11
17
color: palevioletred;
12
18
margin: 0;
13
19
` ;
14
20
21
+ const codeString = `
22
+ module.exports = {
23
+ devtool: 'inline-source-map',
24
+ entry: './src/index.js',
25
+ output: {
26
+ path: path.join(__dirname, '/build'),
27
+ publicPath: '/',
28
+ filename: 'bundle.js'
29
+ },
30
+ optimization: {
31
+ splitChunks: {
32
+ chunks: 'all'
33
+ }
34
+ },
35
+ devServer: {
36
+ contentBase: './build'
37
+ },
38
+ module: {
39
+ rules: [
40
+ {
41
+ test: /\.(js|jsx)$/,
42
+ exclude: /node_modules/,
43
+ use: ['babel-loader', 'eslint-loader']
44
+ }
45
+ ]
46
+ },
47
+ plugins: [
48
+ new HtmlWebpackPlugin({
49
+ template: path.resolve('./index.html')
50
+ }),
51
+ new BundleAnalyzerPlugin({
52
+ analyzerMode: 'disabled',
53
+ generateStatsFile: true,
54
+ statsOptions: { source: false },
55
+ statsFilename: path.join(__dirname, 'stats/stats.json')
56
+ })
57
+ ],
58
+ performance: { hints: false }
59
+ };
60
+
61
+ ` ;
62
+
15
63
class Welcome extends React . Component {
16
64
render ( ) {
17
- return < Title > Hello World</ Title > ;
65
+ return (
66
+ < React . Fragment >
67
+ < Title > JavaScript</ Title >
68
+ < SyntaxHighlighter language = "javascript" style = { railscasts } customStyle = { { fontSize : '1.25rem' } } >
69
+ { codeString }
70
+ </ SyntaxHighlighter >
71
+ </ React . Fragment >
72
+ ) ;
18
73
}
19
74
}
20
75
0 commit comments