1 Star 0 Fork 0

acrowise / ReacType

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
webpack.production.js 3.10 KB
一键复制 编辑 原始数据 按行查看 历史
Jonathan Calvo 提交于 2021-05-12 12:49 . Added Comment to unminify code
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CspHtmlWebpackPlugin = require('csp-html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const merge = require('webpack-merge');
const base = require('./webpack.config');
const path = require('path');
const nonce = require('./app/src/utils/createNonce')();
// merges webpack.config.js with production specific configs
module.exports = merge(base, {
// enables optimizations for production mode
// sets process.env.NODE_ENV to 'production'
mode: 'production',
// nosources-source-map exposes filenames/structure for stack traces but not the rest of the soruce cdoe
// devtool: 'source-map', //https://webpack.js.org/configuration/devtool/ && https://github.com/webpack/webpack/issues/5627#issuecomment-389492939
// optimization: {
// minimize: false,
// },
plugins: [
// miniCssExtractPlugin is included here because it's used as a loader in wepack.config.js
new MiniCssExtractPlugin(),
// simplifies creation of HTML files that serve webpack bundles
// creates a index.html file in the dist folder using index.html as a template
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'app/src/public/index-prod.ejs'),
filename: 'index-prod.html',
nonce: nonce
})
// TODO: Fix CSP so it will work with external style sheets
// // enerate meta content for your Content Security Policy tag and input the correct data into your HTML template
// // Content-Security-Policy response header allows web site administrators to control resources the user agent is allowed to load for a given page
// // policies mostly involve specifying server origins and script endpoints. This helps guard against cross-site scripting attacks
// new CspHtmlWebpackPlugin(
// {
// // only include URIs from the base URL /port
// // TODO: update this URI to allow requests to github
// "base-uri": ["'self'"],
// // object-src is a legacy html feature that's not supported anymore
// // the CSP is restricting this type of element
// "object-src": ["'none'"],
// // specifies valid directories for JS scripts
// // doc can only be served from same url scheme/PORT
// //TODO: may also need to update this for github
// "script-src": ["'self'"],
// // only allow styles from the same URL/port or styles that have a specific nonce
// // the nonce is necessary here so that Material UI styles can render with the CSP
// // https://material-ui.com/styles/advanced/#content-security-policy-csp
// // https://github.com/reZach/secure-electron-template/issues/14metap
// "style-src": ["'self'", `'nonce-${nonce}'`],
// // does not allow nested browsing contexts (frame/iframe)
// "frame-src": ["'none'"],
// // do not allow worker scripts
// "worker-src": ["'none'"],
// },
// {
// // entry for which policy rules are allowed to include hashes
// hashEnabled: {
// "style-src": false,
// },
// }
// ),
]
});
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/acrowise/ReacType.git
git@gitee.com:acrowise/ReacType.git
acrowise
ReacType
ReacType
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891