const webpack = require( webpack );
const path = require( path );
const crypto = require( crypto );
const emotionalNonce = crypto.randomBytes(16).toString( base64 );
const emotionalNonce1 = crypto.randomBytes(16).toString( base64 );
const MiniCssExtractPlugin = require( mini-css-extract-plugin );
const CspHtmlWebpackPlugin = require( csp-html-webpack-plugin );
module.exports = {
publicPath: process.env.VUE_APP_BASE_URL,
configureWebpack: {
devServer: {
hot: false
},
devtool: source-map ,
plugins: [
new webpack.DefinePlugin({
process.env.EMOTIONAL_NONCE : JSON.stringify(emotionalNonce),
}),
new MiniCssExtractPlugin({
filename: path.resolve(__dirname, ../dist/css/[name].[hash:8].css ),
chunkFilename: "[name].[hash:8].css",
attributes: {
nonce: emotionalNonce,
}
}),
new CspHtmlWebpackPlugin({
base-uri : " self ",
object-src : " none ",
script-src : [" self ",` nonce-${emotionalNonce1} `],
style-src : [ " self ","fonts.googleapis.com",` nonce-${emotionalNonce} `]
}, {
enabled: true,
hashingMethod: sha256 ,
hashEnabled: {
script-src : true,
style-src : true
},
nonceEnabled: {
script-src : true,
style-src : true
},
})
],
module: {
rules: [
{
test: /.s(c|a)ss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: css-loader ,
options: {
sourceMap: true,
}
},
{
loader: sass-loader ,
options: {
implementation: require( sass ),
sassOptions: {
indentedSyntax: false // optional
}
}
}
]
}
]
}
},
};