Webpack.config.js for Power-Up
This file contains 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 CopyWebpackPlugin = require("copy-webpack-plugin"); | |
const HtmlWebpackPlugin = require("html-webpack-plugin"); | |
const fs = require("fs"); | |
module.exports = async (env, options) => { | |
const isProduction = options.mode === 'production'; | |
const config = { | |
devtool: isProduction ? false : 'source-map', | |
mode: isProduction ? "production" : "development", | |
entry: { | |
details: "./js/details.js", | |
client: "./js/client.js", | |
}, | |
output: { | |
devtoolModuleFilenameTemplate: "webpack:///[resource-path]?[loaders]", | |
clean: true, | |
}, | |
resolve: { | |
extensions: [".ts", ".tsx", ".html", ".js"], | |
}, | |
module: { }, | |
plugins: [ | |
new HtmlWebpackPlugin({ | |
filename: "index.html", | |
template: "./views/index.html", | |
chunks: ["client"], | |
}), | |
new HtmlWebpackPlugin({ | |
filename: "details.html", | |
template: "./views/index.html", | |
chunks: ["details"], | |
}), | |
], | |
devServer: { | |
hot: true, | |
headers: { | |
"Access-Control-Allow-Origin": "*", | |
}, | |
https: env.WEBPACK_BUILD || options.https !== undefined ? options.https : { | |
key: fs.readFileSync('./certs/server.key'), | |
cert: fs.readFileSync('./certs/server.crt'), | |
}, | |
port: process.env.npm_package_config_dev_server_port || 12345, | |
}, | |
}; | |
return config; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment