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