Comments (4)
Hi,
I'm not sure what you are talking about, this ticket need details, how to reproduce each of the issue you are having. Because I don't have any problems with images, everything works as expected.
from apollo-universal-starter-kit.
No problem @Vlasenko, hopefully the following will suffice.
Basically I have a div with a class of .brief
. Inside of .brief
I have the following defined:
.brief {
color: white;
position: relative;
background: $violet url('../../assets/images/bg/bg_brand-blocks.png');
background-position: center;
background-repeat: no-repeat;
background-size: contain;
}
When I turn off Javascript in the browser (rendering pure SSR only) the image background png doesn't load. Inspecting the element looks like this:
When I turn Javascript back on the image renders in the browser and inspector results in this:
The behavior for an SVG background-image is a little different. It never loads.
With or without Javascript enabled:
Opening this url leads me here:
Just to be even more thorough the following is my webpack config, it shouldn't be any different from this project:
// Don't use ES6 here to stay compatible with ESLint plugins
const webpack = require('webpack');
const ManifestPlugin = require('webpack-manifest-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const merge = require('webpack-merge');
const nodeExternals = require('webpack-node-externals');
const path = require('path');
const pkg = require('../package.json');
const _ = require('lodash');
global.__DEV__ = process.argv.length >= 3 && process.argv[2] === 'watch';
const buildNodeEnv = __DEV__ ? 'development' : 'production';
let basePlugins = [];
if (__DEV__) {
basePlugins.push(new webpack.NamedModulesPlugin());
} else {
basePlugins.push(new webpack.optimize.UglifyJsPlugin({ minimize: true }));
}
const baseConfig = {
module: {
noParse: [],
loaders: [
{
test: /\.jsx?$/,
loader: 'babel',
exclude: /(node_modules|bower_components)/,
query: {
cacheDirectory: __DEV__,
presets: ['es2015', 'es2017', 'react'],
plugins: ['transform-runtime', 'transform-decorators-legacy', 'transform-class-properties'],
},
},
{ test: /\.json$/, loader: 'json' },
{ test: /\.graphqls/, loader: 'raw' },
{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader'
},
{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url-loader?limit=10000&minetype=application/font-woff" },
{ test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" }
]
},
resolve: {
root: path.resolve(__dirname, '../src'),
modulesDirectories: ['node_modules'],
extensions: ['', '.js', '.jsx']
},
plugins: basePlugins,
bail: !__DEV__
};
let serverPlugins = [
new webpack.BannerPlugin('require("source-map-support").install();',
{ raw: true, entryOnly: false }),
new webpack.DefinePlugin(Object.assign({__CLIENT__: false, __SERVER__: true, __SSR__: pkg.app.ssr,
__DEV__: __DEV__, 'process.env.NODE_ENV': `"${buildNodeEnv}"`}))
];
const serverConfig = merge.smart(_.cloneDeep(baseConfig), {
devtool: __DEV__ ? '#cheap-module-source-map' : '#source-map',
target: 'node',
entry: {
index: ['babel-polyfill', './src/server/index.js']
},
node: {
__dirname: true,
__filename: true
},
externals: nodeExternals({
whitelist: [/^webpack/]
}),
module: {
loaders: [
{
test: /\.scss$/,
loaders: __DEV__ ? [
'isomorphic-style-loader',
'css',
'postcss',
'sass'] : ['ignore-loader']
},
{ test: /\.(woff2?|svg|png|ico|jpg|ttf|eot)$/, loader: 'ignore-loader' }
]
},
output: {
devtoolModuleFilenameTemplate: __DEV__ ? '../../[resource-path]' : undefined,
devtoolFallbackModuleFilenameTemplate: __DEV__ ? '../../[resource-path];[hash]' : undefined,
filename: '[name].js',
sourceMapFilename: '[name].[chunkhash].js.map',
path: pkg.app.backendBuildDir,
publicPath: '/'
},
plugins: serverPlugins
});
let clientPlugins = [
new ManifestPlugin({
fileName: 'assets.json'
}),
new webpack.DefinePlugin(Object.assign({__CLIENT__: true, __SERVER__: false, __SSR__: pkg.app.ssr,
__DEV__: __DEV__, 'process.env.NODE_ENV': `"${buildNodeEnv}"`})),
];
if (!__DEV__) {
clientPlugins.push(new ExtractTextPlugin('[name].[contenthash].css', { allChunks: true }));
clientPlugins.push(new webpack.optimize.CommonsChunkPlugin(
"vendor",
"[name].[hash].js",
function (module) {
return module.resource && module.resource.indexOf(path.resolve('./node_modules')) === 0;
}
));
}
const clientConfig = merge.smart(_.cloneDeep(baseConfig), {
devtool: __DEV__ ? '#eval' : '#source-map',
entry: {
bundle: ['babel-polyfill', './src/client/index.jsx']
},
module: {
loaders: [
{
test: /\.scss$/,
loader: __DEV__ ? 'style!css?importLoaders=1!postcss?sourceMap=inline!sass' : ExtractTextPlugin.extract("style", "css!postcss!sass")
},
{ test: /\.(woff2?|svg|png|ico|jpg|xml)$/, loader: 'url?name=[hash].[ext]&limit=10000' },
{ test: /\.(ttf|eot)$/, loader: 'file?name=[hash].[ext]' },
]
},
output: {
filename: '[name].[hash].js',
path: pkg.app.frontendBuildDir,
publicPath: '/'
},
plugins: clientPlugins
});
const dllConfig = merge.smart(_.cloneDeep(baseConfig), {
entry: {
vendor: _.keys(pkg.dependencies),
},
plugins: [
new webpack.DllPlugin({
name: '[name]',
path: path.join(pkg.app.frontendBuildDir, '[name]_dll.json'),
}),
],
output: {
filename: '[name].[hash]_dll.js',
path: pkg.app.frontendBuildDir,
library: '[name]',
},
});
module.exports =
process.argv.length >= 2 && process.argv[1].indexOf('mocha-webpack') >= 0 ?
serverConfig :
[ serverConfig, clientConfig, dllConfig ];
If there's any other information you need please let me know, thank you for looking into this!
from apollo-universal-starter-kit.
Yes, you are right. I have introduced the problem in backend webpack config. Frontend and backend should use the SAME config for images. It was the same from the beginning, but at some stage, I just started to use ignore-loader
on backend for images. It was a mistake. I have returned back the same config for images for backend and frontend. See the commit above. If you have more questions about images, lets discuss.
from apollo-universal-starter-kit.
Thanks @Vlasenko this solution worked.
from apollo-universal-starter-kit.
Related Issues (20)
- Multi Config Setup HOT 2
- Can't fully install dependencies after fresh download - expo-yarn-workspace postinstall fails HOT 4
- lerna stdout maxBuffer exceeded HOT 7
- [Question] Are there any plans to shift to any other package manager since lerna is no longer properly maintained. HOT 5
- Unable to perform a full page reload on edit post page in React Client. HOT 2
- Tests fail after clean installation
- feedback
- Update dependency react-navigation HOT 1
- How can i connect it with my Hasura database?
- Plans to upgrade to webpack 5 HOT 3
- Fail to build on a clean Fedora 33 installation
- Expo Go Android will not run. Says wrong sdk version of expo HOT 1
- New @server app dependencies install error (ambiguous syntax error)
- Standalone use
- master does not work
- Upgrade expo to latest SDK HOT 6
- Setting i18n debug to true reveals several potential issues
- Router is not worked ! HOT 6
- ..
- Demo app link on the readme file not working HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apollo-universal-starter-kit.