Webpack loader from docx to html raw.
npm i docx-loader --save-dev
or
yarn add docx-loader -D
{
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"
]
},
}
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 }} />;