Created
August 29, 2019 11:00
-
-
Save mizchi/0af8dee5c682a0f9ef8470a089ec41b9 to your computer and use it in GitHub Desktop.
build battel 用の資料
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 path = require("path"); | |
const { CleanWebpackPlugin } = require("clean-webpack-plugin"); | |
const HTMLPlugin = require("html-webpack-plugin"); | |
const WorkerPlugin = require("worker-plugin"); | |
const CopyPlugin = require("copy-webpack-plugin"); | |
const { GenerateSW } = require("workbox-webpack-plugin"); | |
const tsLoader = { | |
loader: "ts-loader", | |
options: { | |
transpileOnly: true | |
} | |
}; | |
module.exports = { | |
entry: { | |
"mdbuf-preview": path.join(__dirname, "src/third_party/mdbuf-preview"), | |
main: path.join(__dirname, "src/main") | |
}, | |
output: { | |
publicPath: process.env.ASSET_HOST || "/", | |
globalObject: "self", | |
filename: "[name].js", | |
chunkFilename: "[name].[id].[contenthash].js" | |
}, | |
resolve: { | |
extensions: [".js", ".ts", ".tsx"] | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.w\.ts$/, | |
use: [ | |
{ | |
loader: "worker-loader", | |
options: { | |
publicPath: process.env.ASSET_HOST || "/", | |
inline: true | |
} | |
}, | |
tsLoader | |
] | |
}, | |
{ | |
test: /\.css$/i, | |
use: ["style-loader", "css-loader"] | |
}, | |
{ | |
test: /\.(jpg|jpeg|png|woff|woff2|eot|ttf|svg)$/, | |
use: [ | |
{ | |
loader: "url-loader", | |
options: { | |
limit: 8192 | |
} | |
} | |
] | |
}, | |
{ | |
test: /\.tsx?/, | |
use: [tsLoader] | |
} | |
] | |
}, | |
plugins: [ | |
new CleanWebpackPlugin(), | |
new WorkerPlugin(), | |
new HTMLPlugin({ | |
template: path.join(__dirname, "src/index.html"), | |
inject: false | |
}), | |
new CopyPlugin([ | |
{ | |
from: "src/manifest.webmanifest", | |
to: "manifest.webmanifest" | |
}, | |
{ | |
from: "src/assets", | |
to: "assets" | |
} | |
]), | |
new GenerateSW({ | |
globDirectory: path.join(__dirname, "dist"), | |
globPatterns: ["*.{html,js,css}"], | |
swDest: "service-worker.js", | |
clientsClaim: true, | |
skipWaiting: true | |
}) | |
] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment