File tree 8 files changed +185
-1
lines changed
8 files changed +185
-1
lines changed Original file line number Diff line number Diff line change 5
5
Button ,
6
6
Container ,
7
7
Header ,
8
+ List ,
9
+ Message ,
8
10
Segment ,
9
11
} from 'src'
10
12
import Logo from '../Components/Logo/Logo'
@@ -173,6 +175,54 @@ const Usage = () => (
173
175
icon = 'github'
174
176
labelPosition = 'left'
175
177
/>
178
+
179
+ < Header as = 'h3' > Webpack 2</ Header >
180
+ < p >
181
+ Webpack 2 fully supports Semantic UI React, it also supports tree shaking. Please ensure that you build your app
182
+ in production mode before release, it will strip < code > propTypes</ code > from your build.
183
+ </ p >
184
+
185
+ < Message warning >
186
+ < p >
187
+ Webpack 2 tree shaking does not completely remove unused exports, there are numerous issues that are
188
+ long-standing bugs:
189
+ </ p >
190
+ < List >
191
+ < List . Item
192
+ icon = 'github'
193
+ content = { < a href = 'https://github.com/webpack/webpack/issues/1750' target = '_blank' > webpack/webpack#1750</ a > }
194
+ />
195
+ < List . Item
196
+ icon = 'github'
197
+ content = { < a href = 'https://github.com/webpack/webpack/issues/2867' target = '_blank' > webpack/webpack#2867</ a > }
198
+ />
199
+ < List . Item
200
+ icon = 'github'
201
+ content = { < a href = 'https://github.com/webpack/webpack/issues/2899' target = '_blank' > webpack/webpack#2899</ a > }
202
+ />
203
+ < List . Item
204
+ icon = 'github'
205
+ content = { < a href = 'https://github.com/webpack/webpack/issues/3092' target = '_blank' > webpack/webpack#3092</ a > }
206
+ />
207
+ </ List >
208
+ < p >
209
+ Semantic UI React imports will be not optimized, so we recommend to use < code > babel-plugin-lodash</ code > in
210
+ your builds. You can find example configuration in < code > examples</ code > directory.
211
+ </ p >
212
+ </ Message >
213
+
214
+ < Button
215
+ content = 'Example configuration'
216
+ href = 'https://github.com/Semantic-Org/Semantic-UI-React/tree/master/examples/webpack2'
217
+ icon = 'github'
218
+ labelPosition = 'left'
219
+ />
220
+ < Button
221
+ content = 'babel-plugin-lodash'
222
+ href = 'https://github.com/lodash/babel-plugin-lodash'
223
+ icon = 'github'
224
+ labelPosition = 'left'
225
+ />
176
226
</ Segment >
177
227
</ Container >
178
228
)
Original file line number Diff line number Diff line change 18
18
"cross-env" : " ^3.2.3" ,
19
19
"react" : " ^15.4.2" ,
20
20
"react-dom" : " ^15.4.2" ,
21
- "semantic-ui-react" : " ^0.67.0 " ,
21
+ "semantic-ui-react" : " ^0.68.3 " ,
22
22
"webpack" : " ^1.12.14"
23
23
},
24
24
"devDependencies" : {
Original file line number Diff line number Diff line change
1
+ {
2
+ "presets" : [
3
+ [" es2015" , {"modules" : false }],
4
+ " react" ,
5
+ " stage-1"
6
+ ],
7
+ "plugins" : [
8
+ [" lodash" , { "id" : [" lodash" , " semantic-ui-react" ] }]
9
+ ]
10
+ }
Original file line number Diff line number Diff line change
1
+ node_modules /
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " semantic-ui-react-example-webpack2" ,
3
+ "version" : " 1.0.0" ,
4
+ "description" : " Get started with Semantic UI React and Webpack 2" ,
5
+ "main" : " index.js" ,
6
+ "scripts" : {
7
+ "build" : " webpack" ,
8
+ "build:production" : " cross-env NODE_ENV=production npm run build"
9
+ },
10
+ "author" :
" Alexander Fedyashov <[email protected] >" ,
11
+ "license" : " MIT" ,
12
+ "dependencies" : {
13
+ "babel-core" : " ^6.24.0" ,
14
+ "babel-loader" : " ^6.4.0" ,
15
+ "babel-preset-es2015" : " ^6.24.0" ,
16
+ "babel-preset-react" : " ^6.23.0" ,
17
+ "babel-preset-stage-1" : " ^6.22.0" ,
18
+ "cross-env" : " ^3.2.3" ,
19
+ "react" : " ^15.4.2" ,
20
+ "react-dom" : " ^15.4.2" ,
21
+ "semantic-ui-react" : " ^0.68.3" ,
22
+ "webpack" : " ^2.3.0"
23
+ },
24
+ "devDependencies" : {
25
+ "webpack-bundle-analyzer" : " ^2.3.1"
26
+ }
27
+ }
Original file line number Diff line number Diff line change
1
+ <!doctype html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < title > Semantic UI React Example</ title >
5
+ < meta charset ="utf-8 ">
6
+ < meta name ="viewport " content ="width=device-width, initial-scale=1 ">
7
+ < link rel ="stylesheet " href ="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.9/semantic.min.css ">
8
+ </ head >
9
+ < body >
10
+ < div id ="root " style ="height: 100% "> </ div >
11
+ < script src ="./dist/app.js "> </ script >
12
+ </ body >
13
+ </ html >
Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+ import { render } from 'react-dom'
3
+ import { Button , Container , Header } from 'semantic-ui-react'
4
+
5
+ const MOUNT_NODE = document . getElementById ( 'root' )
6
+
7
+ const App = ( ) => (
8
+ < Container >
9
+ < Header as = 'h1' > Hello world!</ Header >
10
+
11
+ < Button
12
+ content = 'Discover docs'
13
+ href = 'http://react.semantic-ui.com'
14
+ icon = 'github'
15
+ labelPosition = 'left'
16
+ />
17
+ </ Container >
18
+ )
19
+
20
+ render ( < App /> , MOUNT_NODE )
Original file line number Diff line number Diff line change
1
+ const BundleAnalyzerPlugin = require ( 'webpack-bundle-analyzer' ) . BundleAnalyzerPlugin
2
+ const path = require ( 'path' )
3
+ const webpack = require ( 'webpack' )
4
+
5
+ const env = process . env . NODE_ENV || 'development'
6
+
7
+ const webpackConfig = {
8
+ name : 'client' ,
9
+ target : 'web' ,
10
+
11
+ entry : {
12
+ app : path . resolve ( 'src/main.js' ) ,
13
+ } ,
14
+
15
+ module : {
16
+ rules : [ {
17
+ test : / \. ( j s | j s x ) $ / ,
18
+ exclude : / n o d e _ m o d u l e s / ,
19
+ loader : 'babel-loader' ,
20
+ } ] ,
21
+ } ,
22
+
23
+ plugins : [
24
+ new webpack . DefinePlugin ( {
25
+ 'process.env' : {
26
+ NODE_ENV : JSON . stringify ( env ) ,
27
+ } ,
28
+ } ) ,
29
+ new BundleAnalyzerPlugin ( ) ,
30
+ ] ,
31
+
32
+ output : {
33
+ filename : '[name].js' ,
34
+ path : path . resolve ( 'public/dist' ) ,
35
+ publicPath : '/' ,
36
+ } ,
37
+
38
+ resolve : {
39
+ modules : [
40
+ path . resolve ( 'src' ) ,
41
+ 'node_modules' ,
42
+ ] ,
43
+ extensions : [ '.js' , '.jsx' ] ,
44
+ } ,
45
+ }
46
+
47
+ if ( env === 'production' ) {
48
+ webpackConfig . plugins . push (
49
+ new webpack . LoaderOptionsPlugin ( {
50
+ minimize : true ,
51
+ debug : false ,
52
+ } ) ,
53
+ new webpack . optimize . UglifyJsPlugin ( {
54
+ compress : {
55
+ unused : true ,
56
+ dead_code : true ,
57
+ warnings : false ,
58
+ } ,
59
+ } )
60
+ )
61
+ }
62
+
63
+ module . exports = webpackConfig
You can’t perform that action at this time.
0 commit comments