Issue after building with importing image to React app
I'm importing images and add it to my react app like this:
import housePhoto from '../../images/photo/my-house1.png';
class House extends Component {
constructor(props) {
super(props);
}
render() {
return (
<a href='#'>
<img src={housePhoto} alt=''/>
</a>
)};
but when I do
npm run nodemon
I have an issue in console:
/home/jack/***/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/index.js:558
throw err;
^
SyntaxError: /home/jack/Документы/*-test/front/src/images/***.png:
Unexpected character '�' (1:0)
How can I fix it?
My webpack.config.js
global.Promise = require('bluebird');
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const publicPath = 'http://localhost:8050/public/assets';
const cssName = process.env.NODE_ENV === 'production' ? 'styles-[hash].css' : 'styles.css';
const jsName = process.env.NODE_ENV === 'production' ? 'bundle-[hash].js' : 'bundle.js';
const plugins = [
new webpack.DefinePlugin({
'process.env': {
BROWSER: JSON.stringify(true),
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
}
}),
new ExtractTextPlugin(cssName)
];
if (process.env.NODE_ENV === 'production') {
plugins.push(
new CleanWebpackPlugin([ 'public/assets/' ], {
root: __dirname,
verbose: true,
dry: false
})
);
plugins.push(new webpack.optimize.DedupePlugin());
plugins.push(new webpack.optimize.OccurenceOrderPlugin());
}
module.exports = {
entry: ['babel-polyfill', './src/client.js'],
debug: process.env.NODE_ENV !== 'production',
resolve: {
root: path.join(__dirname, 'src'),
modulesDirectories: [ 'node_modules' ],
extensions: ['', '.js', '.jsx']
},
plugins,
output: {
path: `${__dirname}/public/assets/`,
filename: jsName,
publicPath
},
module: {
loaders: [
{
test: /.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader')
},
{
test: /.less$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader!less-loader')
},
{ test: /.gif$/, loader: 'url-loader?limit=10000&mimetype=image/gif' },
{ test: /.jpg$/, loader: 'url-loader?limit=10000&mimetype=image/jpg' },
{ test: /.png$/, loader: 'url-loader?limit=10000&mimetype=image/png' },
{ test: /.svg/, loader: 'url-loader?limit=26000&mimetype=image/svg+xml' },
{ test: /.(woff|woff2|ttf|eot)/, loader: 'url-loader?limit=1' },
{
test: /.jsx?$/, loader: process.env.NODE_ENV !== 'production' ? 'react-hot!babel!eslint-loader' : 'babel',
exclude: [/node_modules/, /public/] },
{ test: /.json$/, loader: 'json-loader' }
]
},
eslint: { configFile: '.eslintrc' },
devtool: process.env.NODE_ENV !== 'production' ? 'source-map' : null,
devServer: {
headers: { 'Access-Control-Allow-Origin': '*' }
}
};
reactjs image webpack webpack-dev-server nodemon
add a comment |
I'm importing images and add it to my react app like this:
import housePhoto from '../../images/photo/my-house1.png';
class House extends Component {
constructor(props) {
super(props);
}
render() {
return (
<a href='#'>
<img src={housePhoto} alt=''/>
</a>
)};
but when I do
npm run nodemon
I have an issue in console:
/home/jack/***/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/index.js:558
throw err;
^
SyntaxError: /home/jack/Документы/*-test/front/src/images/***.png:
Unexpected character '�' (1:0)
How can I fix it?
My webpack.config.js
global.Promise = require('bluebird');
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const publicPath = 'http://localhost:8050/public/assets';
const cssName = process.env.NODE_ENV === 'production' ? 'styles-[hash].css' : 'styles.css';
const jsName = process.env.NODE_ENV === 'production' ? 'bundle-[hash].js' : 'bundle.js';
const plugins = [
new webpack.DefinePlugin({
'process.env': {
BROWSER: JSON.stringify(true),
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
}
}),
new ExtractTextPlugin(cssName)
];
if (process.env.NODE_ENV === 'production') {
plugins.push(
new CleanWebpackPlugin([ 'public/assets/' ], {
root: __dirname,
verbose: true,
dry: false
})
);
plugins.push(new webpack.optimize.DedupePlugin());
plugins.push(new webpack.optimize.OccurenceOrderPlugin());
}
module.exports = {
entry: ['babel-polyfill', './src/client.js'],
debug: process.env.NODE_ENV !== 'production',
resolve: {
root: path.join(__dirname, 'src'),
modulesDirectories: [ 'node_modules' ],
extensions: ['', '.js', '.jsx']
},
plugins,
output: {
path: `${__dirname}/public/assets/`,
filename: jsName,
publicPath
},
module: {
loaders: [
{
test: /.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader')
},
{
test: /.less$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader!less-loader')
},
{ test: /.gif$/, loader: 'url-loader?limit=10000&mimetype=image/gif' },
{ test: /.jpg$/, loader: 'url-loader?limit=10000&mimetype=image/jpg' },
{ test: /.png$/, loader: 'url-loader?limit=10000&mimetype=image/png' },
{ test: /.svg/, loader: 'url-loader?limit=26000&mimetype=image/svg+xml' },
{ test: /.(woff|woff2|ttf|eot)/, loader: 'url-loader?limit=1' },
{
test: /.jsx?$/, loader: process.env.NODE_ENV !== 'production' ? 'react-hot!babel!eslint-loader' : 'babel',
exclude: [/node_modules/, /public/] },
{ test: /.json$/, loader: 'json-loader' }
]
},
eslint: { configFile: '.eslintrc' },
devtool: process.env.NODE_ENV !== 'production' ? 'source-map' : null,
devServer: {
headers: { 'Access-Control-Allow-Origin': '*' }
}
};
reactjs image webpack webpack-dev-server nodemon
add a comment |
I'm importing images and add it to my react app like this:
import housePhoto from '../../images/photo/my-house1.png';
class House extends Component {
constructor(props) {
super(props);
}
render() {
return (
<a href='#'>
<img src={housePhoto} alt=''/>
</a>
)};
but when I do
npm run nodemon
I have an issue in console:
/home/jack/***/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/index.js:558
throw err;
^
SyntaxError: /home/jack/Документы/*-test/front/src/images/***.png:
Unexpected character '�' (1:0)
How can I fix it?
My webpack.config.js
global.Promise = require('bluebird');
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const publicPath = 'http://localhost:8050/public/assets';
const cssName = process.env.NODE_ENV === 'production' ? 'styles-[hash].css' : 'styles.css';
const jsName = process.env.NODE_ENV === 'production' ? 'bundle-[hash].js' : 'bundle.js';
const plugins = [
new webpack.DefinePlugin({
'process.env': {
BROWSER: JSON.stringify(true),
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
}
}),
new ExtractTextPlugin(cssName)
];
if (process.env.NODE_ENV === 'production') {
plugins.push(
new CleanWebpackPlugin([ 'public/assets/' ], {
root: __dirname,
verbose: true,
dry: false
})
);
plugins.push(new webpack.optimize.DedupePlugin());
plugins.push(new webpack.optimize.OccurenceOrderPlugin());
}
module.exports = {
entry: ['babel-polyfill', './src/client.js'],
debug: process.env.NODE_ENV !== 'production',
resolve: {
root: path.join(__dirname, 'src'),
modulesDirectories: [ 'node_modules' ],
extensions: ['', '.js', '.jsx']
},
plugins,
output: {
path: `${__dirname}/public/assets/`,
filename: jsName,
publicPath
},
module: {
loaders: [
{
test: /.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader')
},
{
test: /.less$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader!less-loader')
},
{ test: /.gif$/, loader: 'url-loader?limit=10000&mimetype=image/gif' },
{ test: /.jpg$/, loader: 'url-loader?limit=10000&mimetype=image/jpg' },
{ test: /.png$/, loader: 'url-loader?limit=10000&mimetype=image/png' },
{ test: /.svg/, loader: 'url-loader?limit=26000&mimetype=image/svg+xml' },
{ test: /.(woff|woff2|ttf|eot)/, loader: 'url-loader?limit=1' },
{
test: /.jsx?$/, loader: process.env.NODE_ENV !== 'production' ? 'react-hot!babel!eslint-loader' : 'babel',
exclude: [/node_modules/, /public/] },
{ test: /.json$/, loader: 'json-loader' }
]
},
eslint: { configFile: '.eslintrc' },
devtool: process.env.NODE_ENV !== 'production' ? 'source-map' : null,
devServer: {
headers: { 'Access-Control-Allow-Origin': '*' }
}
};
reactjs image webpack webpack-dev-server nodemon
I'm importing images and add it to my react app like this:
import housePhoto from '../../images/photo/my-house1.png';
class House extends Component {
constructor(props) {
super(props);
}
render() {
return (
<a href='#'>
<img src={housePhoto} alt=''/>
</a>
)};
but when I do
npm run nodemon
I have an issue in console:
/home/jack/***/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/index.js:558
throw err;
^
SyntaxError: /home/jack/Документы/*-test/front/src/images/***.png:
Unexpected character '�' (1:0)
How can I fix it?
My webpack.config.js
global.Promise = require('bluebird');
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const publicPath = 'http://localhost:8050/public/assets';
const cssName = process.env.NODE_ENV === 'production' ? 'styles-[hash].css' : 'styles.css';
const jsName = process.env.NODE_ENV === 'production' ? 'bundle-[hash].js' : 'bundle.js';
const plugins = [
new webpack.DefinePlugin({
'process.env': {
BROWSER: JSON.stringify(true),
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
}
}),
new ExtractTextPlugin(cssName)
];
if (process.env.NODE_ENV === 'production') {
plugins.push(
new CleanWebpackPlugin([ 'public/assets/' ], {
root: __dirname,
verbose: true,
dry: false
})
);
plugins.push(new webpack.optimize.DedupePlugin());
plugins.push(new webpack.optimize.OccurenceOrderPlugin());
}
module.exports = {
entry: ['babel-polyfill', './src/client.js'],
debug: process.env.NODE_ENV !== 'production',
resolve: {
root: path.join(__dirname, 'src'),
modulesDirectories: [ 'node_modules' ],
extensions: ['', '.js', '.jsx']
},
plugins,
output: {
path: `${__dirname}/public/assets/`,
filename: jsName,
publicPath
},
module: {
loaders: [
{
test: /.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader')
},
{
test: /.less$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader!less-loader')
},
{ test: /.gif$/, loader: 'url-loader?limit=10000&mimetype=image/gif' },
{ test: /.jpg$/, loader: 'url-loader?limit=10000&mimetype=image/jpg' },
{ test: /.png$/, loader: 'url-loader?limit=10000&mimetype=image/png' },
{ test: /.svg/, loader: 'url-loader?limit=26000&mimetype=image/svg+xml' },
{ test: /.(woff|woff2|ttf|eot)/, loader: 'url-loader?limit=1' },
{
test: /.jsx?$/, loader: process.env.NODE_ENV !== 'production' ? 'react-hot!babel!eslint-loader' : 'babel',
exclude: [/node_modules/, /public/] },
{ test: /.json$/, loader: 'json-loader' }
]
},
eslint: { configFile: '.eslintrc' },
devtool: process.env.NODE_ENV !== 'production' ? 'source-map' : null,
devServer: {
headers: { 'Access-Control-Allow-Origin': '*' }
}
};
reactjs image webpack webpack-dev-server nodemon
reactjs image webpack webpack-dev-server nodemon
asked Nov 28 '18 at 21:22
JackJack
648
648
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Problem solved by changing img tag:
<img src={require('../../images/photo/my-house1.png')} />
add a comment |
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53528325%2fissue-after-building-with-importing-image-to-react-app%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Problem solved by changing img tag:
<img src={require('../../images/photo/my-house1.png')} />
add a comment |
Problem solved by changing img tag:
<img src={require('../../images/photo/my-house1.png')} />
add a comment |
Problem solved by changing img tag:
<img src={require('../../images/photo/my-house1.png')} />
Problem solved by changing img tag:
<img src={require('../../images/photo/my-house1.png')} />
answered Nov 29 '18 at 13:06
JackJack
648
648
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53528325%2fissue-after-building-with-importing-image-to-react-app%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown