Skip to content

gigantz/docx-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Documentation

Webpack loader from docx to html raw.

docx-loader

docx-loader

npm i docx-loader --save-dev

or

yarn add docx-loader -D

Add it in your webpack config file

{
  test: /\.docx$/,
  use: [
    {
      loader: "docx-loader",
      options: {
        removeLinks: true
      }
    }
  ]
}

You can also add options

  options: {
    removeLinks: true,
    mammoth: { // we're using mammoth npm package for docx2html
      styleMap: [
        "p[style-name='Section Title'] => h1:fresh",
        "p[style-name='Subsection Title'] => h2:fresh"
      ]
    },
  }

How it works

import demo from "./demo.docx";
console.log(demo); // <div><h1>Demo...

document.body.innerHtml = demo;

or with React

import demo from "./demo.docx";
export default <div dangerouslySetInnerHTML={{ __html: demo }} />;

About

Word document to raw html loader for Webpack

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published