I have a react project where I am refactoring the dependency tree and when I run the build I get no output but the project clearly doesn’t build. The output directory isn’t created. It is almost certainly a dependency issue since I am changing versions of things but I am unable to figure out which one since there is no output.
How can I get webpack to tell me why it isn’t building? The verbose logging doesn’t produce anything.
The only output is:
yarn run v1.22.19
warning package.json: "dependencies" has dependency "typescript" with range "4.3.2" that collides with a dependency in "devDependencies" of the same name with version "^4.3.2"
$ webpack --config webpack.staging.js && node set-csp.js
[webpack-cli] Compiler starting...
[webpack-cli] Compiler is using config: '<my config path>'
This is the webpack file which I know works since i can use it against the main branch and everything builds.
```const path = require("path");
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CspHtmlWebpackPlugin = require('csp-html-webpack-plugin');
const HtmlWebpackPlugin = require("html-webpack-plugin");
const Dotenv = require("dotenv-webpack");
const webpack = require('webpack');
const contentSecurity = {
connectSrc: [
<snip> ....
],
};
module.exports = {
infrastructureLogging: {
level: 'verbose',
},
mode: 'production',
entry: {
index: path.join(__dirname, 'src', 'index.tsx')
},
plugins: [
new webpack.ProvidePlugin({
process: 'process/browser',
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
new Dotenv(),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, "public", "index.html"),
filename: 'index.html',
favicon: path.resolve(__dirname, "public", "favicon.ico"),
}),
// Copy solution files
new CopyWebpackPlugin({
patterns: [
{from: "./src/assets/images", to: './assets/images/'},
{from: "./src/assets/portal-logos", to: './imgs/'},
{from: "./public/web.config", to: './web.config'}
]
}),
new CspHtmlWebpackPlugin({
'default-src': ["'self'"],
'connect-src': contentSecurity.connectSrc,
'frame-src': contentSecurity.frameSrc,
'script-src': [ "'self'"],
'worker-src': ["'self'", "blob:"],
'style-src': ["'self'", "'unsafe-inline'"],
'img-src': contentSecurity.imgSrc,
'form-action': ["'self'"]
}, {
enabled: true,
hashingMethod: 'sha256',
hashEnabled: {
'script-src': true,
'style-src': true
},
nonceEnabled: {
'script-src': true,
'style-src': true
}
})
],
module: {
rules: [
{
test: /.js$/,
loader: 'babel-loader',
exclude: /node_modules/(?!(jsoneditor)/).*/,
options: {
presets: ["@babel/preset-env"]
}
},
{
test: /.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /.css$/i,
use: ['style-loader', 'css-loader'],
},
{
test: /.svg$/,
loader: 'file-loader'
}
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
fallback: {
"path": require.resolve("path-browserify"),
"crypto": require.resolve("crypto-browserify"),
"stream": require.resolve("stream-browserify"),
"buffer": require.resolve("buffer")
},
},
output: {
path: path.resolve(__dirname, 'build'),
filename: 'index_bundle.js',
publicPath: '/',
},
};