-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(bundlers): add webpack 2 example
- Loading branch information
1 parent
3fd65da
commit 199877e
Showing
9 changed files
with
149 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ const App = () => ( | |
</Container> | ||
) | ||
|
||
render(App, MOUNT_NODE) | ||
render(<App />, MOUNT_NODE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"presets": [ | ||
["es2015", {"modules": false}], | ||
"react", | ||
"stage-1" | ||
], | ||
"plugins": [ | ||
"lodash" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "semantic-ui-react-example-webpack2", | ||
"version": "1.0.0", | ||
"description": "Get started with Semantic UI React and Webpack 2", | ||
"main": "index.js", | ||
"scripts": { | ||
"build": "webpack", | ||
"build:production": "cross-env NODE_ENV=production npm run build" | ||
}, | ||
"author": "Alexander Fedyashov <a@fedyashov.com>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"babel-core": "^6.24.0", | ||
"babel-loader": "^6.4.0", | ||
"babel-preset-es2015": "^6.24.0", | ||
"babel-preset-react": "^6.23.0", | ||
"babel-preset-stage-1": "^6.22.0", | ||
"cross-env": "^3.2.3", | ||
"react": "^15.4.2", | ||
"react-dom": "^15.4.2", | ||
"semantic-ui-react": "^0.67.0", | ||
"webpack": "^2.3.0" | ||
}, | ||
"devDependencies": { | ||
"webpack-bundle-analyzer": "^2.3.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<title>Semantic UI React Example</title> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.9/semantic.min.css"> | ||
</head> | ||
<body> | ||
<div id="root" style="height: 100%"></div> | ||
<script src="./dist/app.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react' | ||
import { render } from 'react-dom' | ||
import { Button, Container, Header } from 'semantic-ui-react' | ||
|
||
const MOUNT_NODE = document.getElementById('root') | ||
|
||
const App = () => ( | ||
<Container> | ||
<Header as='h1'>Hello world!</Header> | ||
|
||
<Button | ||
content='Discover docs' | ||
href='http://react.semantic-ui.com' | ||
icon='github' | ||
labelPosition='left' | ||
/> | ||
</Container> | ||
) | ||
|
||
render(<App />, MOUNT_NODE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin | ||
const path = require('path') | ||
const webpack = require('webpack') | ||
|
||
const env = process.env.NODE_ENV || 'development' | ||
|
||
const webpackConfig = { | ||
name: 'client', | ||
target: 'web', | ||
|
||
entry: { | ||
app: path.resolve('src/main.js'), | ||
}, | ||
|
||
module: { | ||
rules: [{ | ||
test: /\.(js|jsx)$/, | ||
exclude: /node_modules/, | ||
loader: 'babel-loader', | ||
}], | ||
}, | ||
|
||
plugins: [ | ||
new webpack.DefinePlugin({ | ||
'process.env': { | ||
NODE_ENV: JSON.stringify(env), | ||
}, | ||
}), | ||
new BundleAnalyzerPlugin(), | ||
], | ||
|
||
output: { | ||
filename: '[name].js', | ||
path: path.resolve('public/dist'), | ||
publicPath: '/', | ||
}, | ||
|
||
resolve: { | ||
modules: [ | ||
path.resolve('src'), | ||
'node_modules', | ||
], | ||
extensions: ['.js', '.jsx'], | ||
}, | ||
} | ||
|
||
if (env === 'production') { | ||
webpackConfig.plugins.push( | ||
new webpack.LoaderOptionsPlugin({ | ||
minimize: true, | ||
debug: false, | ||
}), | ||
new webpack.optimize.UglifyJsPlugin({ | ||
compress: { | ||
unused: true, | ||
dead_code: true, | ||
warnings: false, | ||
}, | ||
}) | ||
) | ||
} | ||
|
||
module.exports = webpackConfig |