Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
8b507a79
Commit
8b507a79
authored
Sep 08, 2017
by
Sergio Xalambrí
Committed by
Tim Neutkens
Sep 08, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Example: Add asset imports example (#2864)
parent
b6649083
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
0 deletions
+68
-0
.babelrc
examples/with-asset-imports/.babelrc
+12
-0
README.md
examples/with-asset-imports/README.md
+39
-0
package.json
examples/with-asset-imports/package.json
+13
-0
index.js
examples/with-asset-imports/pages/index.js
+4
-0
logo.png
examples/with-asset-imports/static/logo.png
+0
-0
No files found.
examples/with-asset-imports/.babelrc
0 → 100644
View file @
8b507a79
{
"presets": ["next/babel"],
"plugins": [
[
"transform-assets-import-to-string",
{
"baseDir": "static",
"baseUri": "/"
}
]
]
}
examples/with-asset-imports/README.md
0 → 100644
View file @
8b507a79
# Example app with asset imports
## How to use
Download the example
[
or clone the repo
](
https://github.com/zeit/next.js
)
:
```
bash
curl https://codeload.github.com/zeit/next.js/tar.gz/master |
tar
-xz
--strip
=
2 next.js-master/examples/with-asset-imports
cd
with-asset-imports
```
Install it and run:
```
bash
npm
install
npm run dev
```
Deploy it to the cloud with
[
now
](
https://zeit.co/now
)
(
[download](https://zeit.co/download
)
)
```
bash
now
```
## The idea behind the example
This example shows how to enable the impors of assets (images, videos, etc.) and get a URL pointing to
`/static`
.
This is also configurable to point to a CDN changing the
`baseUri`
to the CDN domain, something similar to this:
```
json
[
"transform-assets-import-to-string"
,
{
"baseDir"
:
"/static"
,
"baseUri"
:
"https://cdn.domain.com"
}
]
```
examples/with-asset-imports/package.json
0 → 100644
View file @
8b507a79
{
"scripts"
:
{
"dev"
:
"next dev"
,
"build"
:
"next build"
,
"start"
:
"next start"
},
"dependencies"
:
{
"babel-plugin-transform-assets-import-to-string"
:
"^1.0.1"
,
"next"
:
"^3.0.6"
,
"react"
:
"^15.6.1"
,
"react-dom"
:
"^15.6.1"
}
}
examples/with-asset-imports/pages/index.js
0 → 100644
View file @
8b507a79
import
avatar
from
'../static/logo.png'
export
default
()
=>
<
img
src
=
{
avatar
}
/
>
examples/with-asset-imports/static/logo.png
0 → 100644
View file @
8b507a79
9.42 KB
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment