-
-
Save dalcib/2987de98c9fbd8322fec5cabc971f3a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"); | |
const bundle = fs.readFileSync("path-to-webpack-bundle.html", "utf8"); | |
const escaped = JSON.stringify(bundle); | |
const js = `export default ${escaped}`; | |
fs.writeFileSync("javascript-output-file.ts", js); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Configuration } from "webpack"; | |
import { resolve } from "path"; | |
import * as HtmlWebpackPlugin from "html-webpack-plugin"; | |
import * as HtmlWebpackInlineSourcePlugin from "html-webpack-inline-source-plugin"; | |
declare var __dirname; | |
const config: Configuration = { | |
entry: "./src/index.ts", | |
output: { | |
path: resolve(__dirname, "dist"), | |
filename: "bundle.js" | |
}, | |
resolve: { | |
alias: { | |
fabric: resolve(__dirname, "fabric.min.js") | |
}, | |
extensions: [".ts", ".js"] | |
}, | |
module: { | |
rules: [ | |
{ test: /\.ts$/, loader: "ts-loader" }, | |
{ test: /\.css$/, use: ["style-loader", "css-loader"] }, | |
{ test: /\.scss$/, use: ["style-loader", "css-loader", "sass-loader"] }, | |
{ | |
test: /\.(jpe?g|png|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/, | |
use: "base64-inline-loader?limit=1000&name=[name].[ext]" | |
} | |
] | |
}, | |
plugins: [ | |
new HtmlWebpackPlugin({ | |
meta: { | |
viewport: "initial-scale=1, maximum-scale=1" | |
}, | |
inlineSource: ".(js|css)$" | |
}), | |
new HtmlWebpackInlineSourcePlugin() | |
] | |
}; | |
export default config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment