Skip to content

Import `.html` files as strings in your Next.js project

Notifications You must be signed in to change notification settings

alexblunck/next-html

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Next.js + Html

Import .html files as strings in your Next.js project

Installation

npm install --save @blunck/next-html

Usage

Create a next.config.js in your project

// next.config.js
const withHtml = require('@blunck/next-html')()
module.exports = withHtml()

You can now import .html files as strings

import foo from './foo.html'

export default () => <div dangerouslySetInnerHTML={{ __html: foo }} />

With html-loader options

Optionally you can provide html-loader options

// next.config.js
const withHtml = require('@blunck/next-html')({
    minimize: true,
    conservativeCollapse: false
})
module.exports = withHtml()

Configuring Next.js

Optionally you can add your custom Next.js configuration as parameter

// next.config.js
const withHtml = require('@blunck/next-html')()
module.exports = withHtml({
    webpack(config, options) {
        return config
    }
})

About

Import `.html` files as strings in your Next.js project

Resources

Stars

Watchers

Forks

Packages

No packages published