Giter Club home page Giter Club logo

Comments (4)

larixer avatar larixer commented on May 12, 2024

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.

josephdburdick avatar josephdburdick commented on May 12, 2024

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:
screen shot 2017-02-26 at 2 27 31 pm

When I turn Javascript back on the image renders in the browser and inspector results in this:
screen shot 2017-02-26 at 2 28 08 pm

The behavior for an SVG background-image is a little different. It never loads.
With or without Javascript enabled:
screen shot 2017-02-26 at 2 31 26 pm

Opening this url leads me here:
screen shot 2017-02-26 at 2 31 43 pm

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.

larixer avatar larixer commented on May 12, 2024

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.

josephdburdick avatar josephdburdick commented on May 12, 2024

Thanks @Vlasenko this solution worked.

from apollo-universal-starter-kit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.