Skip to content

Instantly share code, notes, and snippets.

@dkwingsmt
Last active August 15, 2017 00:54
Show Gist options
  • Select an option

  • Save dkwingsmt/7325377c3758f7779e9848c5297893e9 to your computer and use it in GitHub Desktop.

Select an option

Save dkwingsmt/7325377c3758f7779e9848c5297893e9 to your computer and use it in GitHub Desktop.
File loader error

Install

npm i

Run

./node_modules/.bin/webpack index.js
ls -l ./webpack.png ./build/webpack.png

Observation

<...>  24375 Aug 14 17:43 ./build/webpack.png
<...>  13203 Aug 14 17:38 ./webpack.png

Expectation

The two files are identical.

const image = require('./webpack.png').default;
{
"name": "file-loader-error",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"file-loader": "^1.0.0",
"webpack": "^3.5.4"
}
}
module.exports = {
entry: [
'./index.js'
],
output: {
path: `${__dirname}/build/`,
filename: 'bundle.js',
publicPath: '/'
},
module: {
rules: [
{
test: /\.png$/,
loader: 'file-loader?name=[name].[ext]'
}
]
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment