1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/examples/with-semantic-ui/pages/index.js
Marcin Czenko 1475491568 Updates with-semantic-ui example (#6158)
I tried to make the example a bit more descriptive. I changed `publicPath` in `now.config.js` to be `/_next/static/`, in place of `./`, and `outputPath` to `static/` in place of `static/css/`.  The reason is that the webpack config will still fallback to `file-loader` for any content that is imported by the user and which is bigger that `8192` bytes. I think this content should not land in the css folder, which should probably stay css specific.

Moreover, for user content, like regular images, the former settings will fail.

If you have this:

```javascript
import LargeFile from './LargeFile.png'
```

it would be placed in `static/css/` but its url would resolve to `<base-url>/LargeFile.png`, which will fail. It works for semantic-ui alone, because `@zeit/next-css` will put the styles in `static/css/` and so `publicPath` of `./` would work just fine.

Putting assets in `static/` and setting `publicPath` to '/_next/static/' will resolve correctly for both semantic-ui related assets as well as for regular user assets.

I hope I am not mixing something up. I tested it locally and in serverless deployment, and this looks pretty consistent.
2019-01-28 08:37:24 +01:00

53 lines
1.6 KiB
JavaScript

import 'semantic-ui-css/semantic.min.css'
import { Modal,
Button,
Icon
} from 'semantic-ui-react'
import SmallImage from './SmallImage.png'
import LargeImage from './LargeImage.png'
import './styles.css'
export default () => (
<div className='centered'>
<Icon size='massive' name='world' />
<div className='separator' />
<Modal trigger={<Button>Show Modal</Button>}>
<Modal.Header><em>publicPath</em> should be set to <em>/_next/static/</em></Modal.Header>
<Modal.Content>
<Modal.Description>
<div className='wrapper'>
<div className='row'>
<p>
Larger content should be still availble as a fallback
to <em>fileLoader</em> but
it should not polute <em>/.next/static/css</em> folder.
You should see two images below.
One, smaller, loaded as data url, and one, bigger, loaded
via url.
</p>
</div>
<div className='row'>
<img src={SmallImage} />
<p>
A small image should be loaded as data url: <em>{SmallImage.substr(0, 100)}...</em>
</p>
</div>
<div className='row'>
<img src={LargeImage} />
<p>
A large image should be loaded as a url: <em>{LargeImage}</em>
</p>
</div>
<p className='border'>
You should also still be able to load regular css.
This text should have border.
</p>
</div>
</Modal.Description>
</Modal.Content>
</Modal>
</div>
)