Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAngelic Sanoy
Full Stack JavaScript Techdegree Student 6,743 Points[emitted] [immutable] issue: File-loader doesn't generate a img folder in my dist - webpack
Hi
<p>I'm certain that I have run all the necessary plugin and it's already inserted in my .json file but my image is still not loading and there's no folder generated on my dist folder.</p>
<p>Check my terminal result <a href="https://ibb.co/713LzYd"> </a></p>
<p>My local server result</p> <p><a href="https://prnt.sc/X0Jfc4bpTQRp"> Frontpage </a></p>
<p><a href=https://ibb.co/4dMLSmk>DOM </a>- the DOM run the 2nd emitted file not the first one that's why it's showing 404.</p>
When I run my dev, looks like the but it looks like the image but it doesn't inject on my .
My app.common.config.js
//default in webpack but you need to call it to make the path works below. __dirname
const path = require("path");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const loader = require("sass-loader");
// For DEv
module.exports = {
entry: "./src/index.js",
module: {
rules: [
{
test: /\.s[ac]ss$/i,
use: [
"style-loader",
"css-loader",
"sass-loader",
]
},
{
test: /\.html$/,
use: ["html-loader"]
},
{
test: /\.(svg|png|jpg|gif)$/,
use: [
{
loader: "file-loader",
options: {
name: '[name].[hash].[ext]',
publicPath: 'assets',
outputPath: 'assets/img',
esModule: false
}
}
]
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: "./src/template.html"
})
]
};
My app.dev.config.js
const path = require("path");
const { merge } = require('webpack-merge')
const common = require("./app.common.config");
// For DEv
module.exports = merge(common,{
mode: "development",
output: {
filename:"main.js",
path: path.resolve(__dirname, "dist"),
},
});
My package.json
{
"name": "webpack-project",
"version": "1.0.0",
"private": true,
"description": "Required to run Webpack",
"main": "index.js",
"scripts_comment_2": [
"scripts is used to run your program",
"you can run two scripts, one for production & one for dev"
],
"scripts": {
"start": "webpack-dev-server --config app.dev.config.js --open",
"build": "webpack --config app.prod.config.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"css-loader": "^6.7.3",
"file-loader": "^6.2.0",
"html-loader": "^4.2.0",
"html-webpack-plugin": "^5.5.0",
"sass": "^1.57.1",
"sass-loader": "^13.2.0",
"style-loader": "^3.3.1",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1",
"webpack-dev-server": "^4.11.1",
"webpack-merge": "^5.8.0"
},
"browser": {
"[module-name]": false
}
}