Merge pull request #428 from dolanmiu/feat/webpack-export
Put docx in a seperate namespace in the browser version
This commit is contained in:
@ -12,18 +12,18 @@
|
||||
|
||||
<script>
|
||||
function generate() {
|
||||
const doc = new Document();
|
||||
const doc = new docx.Document();
|
||||
|
||||
doc.addSection({
|
||||
children: [
|
||||
new Paragraph({
|
||||
new docx.Paragraph({
|
||||
children: [
|
||||
new TextRun("Hello World"),
|
||||
new TextRun({
|
||||
new docx.TextRun("Hello World"),
|
||||
new docx.TextRun({
|
||||
text: "Foo Bar",
|
||||
bold: true,
|
||||
}),
|
||||
new TextRun({
|
||||
new docx.TextRun({
|
||||
text: "Github is the best",
|
||||
bold: true,
|
||||
}).tab(),
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
|
||||
|
||||
Packer.toBlob(doc).then((blob) => {
|
||||
docx.Packer.toBlob(doc).then((blob) => {
|
||||
console.log(blob);
|
||||
saveAs(blob, "example.docx");
|
||||
console.log("Document created successfully");
|
||||
|
@ -9,6 +9,7 @@ module.exports = {
|
||||
path: path.resolve("build"),
|
||||
filename: "index.js",
|
||||
libraryTarget: "umd",
|
||||
library: "docx",
|
||||
},
|
||||
|
||||
resolve: {
|
||||
@ -24,15 +25,16 @@ module.exports = {
|
||||
},
|
||||
// For coverage testing
|
||||
...(process.env.NODE_ENV !== "production"
|
||||
? [{
|
||||
? [
|
||||
{
|
||||
test: /\.(ts)/,
|
||||
include: path.resolve("src"),
|
||||
loader: "istanbul-instrumenter-loader",
|
||||
enforce: "post",
|
||||
exclude: [/node_modules/],
|
||||
}]
|
||||
: []
|
||||
)
|
||||
},
|
||||
]
|
||||
: []),
|
||||
],
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user