Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with prefetched files #28

Open
RubenGuerrero opened this issue Nov 8, 2016 · 0 comments
Open

Problem with prefetched files #28

RubenGuerrero opened this issue Nov 8, 2016 · 0 comments

Comments

@RubenGuerrero
Copy link

This is my webpack file:

var webpack = require('webpack');
var path = require('path');

var autoprefixer = require('autoprefixer');

var ExtractTextPlugin = require('extract-text-webpack-plugin');
var ManifestRevisionPlugin = require('manifest-revision-webpack-plugin');

var rootAssetPath = './src/static';

var FLASK_URL = process.env.FLASK_URL;
var publicURL = (FLASK_URL ? FLASK_URL : '/');

var plugins = [
  new webpack.DefinePlugin({
    'process.env.NODE_ENV': JSON.stringify('production')
  }),
  new ManifestRevisionPlugin(path.join('build', 'manifest.json'), {
      rootAssetPath: rootAssetPath,
      ignorePaths: ['/styles', '/scripts', /\.DS_Store/, /sitemap\.xml/, /robots\.txt/]
  }),
  new ExtractTextPlugin('[name].[chunkhash].css')
];

if(process.env.NODE_ENV === 'production'){
  plugins.push(new webpack.optimize.UglifyJsPlugin({
    compress: {
      warnings: false
    }
  }));
}

module.exports = {
    entry: {
        app_css: [
            rootAssetPath + '/styles/main.scss'
        ],
        landing_css: [
            rootAssetPath + '/styles/main-landing.scss'
        ],
        app_js: [
            rootAssetPath + '/scripts/entry.js'
        ]
    },
    output: {
        path: './build/public',
        publicPath: publicURL + 'public/',
        filename: '[name].[chunkhash].js',
        chunkFilename: '[id].[chunkhash].js'
    },
    resolve: {
        extensions: ['', '.js', '.css', '.scss', '.ttf', '.woff', '.svg'],
        modulesDirectories: ['node_modules'],
        alias: {
          'handlebars' : 'handlebars/dist/handlebars.js'
        },
        root: path.resolve(__dirname, 'modules')
    },
    module: {
        preLoaders: [{
          test: /\.js$/i,
          exclude: /node_modules/,
          loader: 'eslint'
        }],
        loaders: [
            {
                test: /\.js$/i,
                loader: 'babel',
                query: {
                  presets: ['es2015', 'stage-0']
                },
                exclude: /node_modules/
            },
            {
                test: /\.(jpe?g|png|svg|ico|gif([\?]?.*))$/i,
                include: [
                  path.resolve(__dirname, 'src'),
                  path.resolve(__dirname, 'modules')
                ],
                loaders: [
                    'file-loader?name=[path][name].[hash].[ext]'/*,
                    'image?bypassOnDebug&optimizationLevel=7&interlaced=false'*/
                ]
            },
            {
              test   : /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
              exclude: [ /images/ ],
              include: [
                path.resolve(__dirname, 'src'),
                path.resolve(__dirname, 'modules')
              ],
              loader : 'url-loader?name=[path][name].[hash].[ext]'
            },
            {
              test: /\.s?css$/,
              loader: ExtractTextPlugin.extract('style', 'css?sourceMap&camelCase&importLoaders=1!postcss!sass?sourceMap')
            }
        ]
    },
    postcss: [autoprefixer],
    plugins: plugins
};

Problem:
If I import a file from .js or .scss files, this file is not wrote on the manifest.json.

Example:

I have photo.png on images folder.
If I don´t do anything with this image all works okey, but if I import photo.png from any .js or .scss file photo.png asset is not printed on manifest.json

Any idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant