1.0.4 • Published 5 years ago

docx-loader v1.0.4

Weekly downloads
155
License
ISC
Repository
github
Last release
5 years ago

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 }} />;