How to allow loading of Webpack 2 loaderUtils.parseQuery ()?

When I compiled my files using Webpack2. He showed the following warning:

"loaderUtils.parseQuery () received a non-line value, which may be problematic, see https://github.com/webpack/loader-utils/issues/56 "

I checked the github page and did not figure out how to solve this problem. This is my configuration:

// webpack 2 configuration // https://webpack.js.org/guides/migrating/ const webpack = require('webpack'); const path = require('path'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); module.exports = { watch: true, inline: true, resolve: { modules: [ 'node_modules', path.resolve(__dirname, './app'), ], //http://webpack.imtqy.com/docs/configuration.html#resolve-alias alias: { lib: path.resolve('./lib'), res: path.resolve('./res'), style: path.resolve('./style'), //make sure it can be load by 'jquery' jquery$: 'jquery', // 01/26/2017 http://isotope.metafizzy.co/extras.html#webpack masonry: 'masonry-layout', isotope: 'isotope-layout' }, extensions: ['.js', '.json', '.jsx', '.css'], }, devtool: 'source-map', target: 'web', // enum entry: { // entry points app: path.resolve('./app') + '/' + 'main.js', //for basic stable library only vendor: ['babel-polyfill', 'jquery', 'lodash', 'react', 'react-dom', 'bootstrap-sass', path.resolve('./app') + '/' + 'vendor.js'], }, output: {path: path.resolve('./script'), publicPath:'script/', filename: '[name].js', /*chunkFilename: '[id].js'*/}, module: { rules: [ { test: /.jsx?$/, loader: 'babel-loader', exclude: /node_modules/, query: { presets: ['es2015', 'react'] } }, { // test: /\.woff2?$|\.ttf$|\.eot$|\.svg$/, // loader: 'file' // https://github.com/webpack/webpack/issues/597 test: /\.woff($|\?)|\.woff2($|\?)|\.ttf($|\?)|\.eot($|\?)|\.svg($|\?)/, loader: 'url-loader' }, // NOTICE: png / jpg needs specific loaders, see https://github.com/webpack-contrib/css-loader { test: /\.png$/, loader: 'url-loader', options: {limit: 100000}, }, { test: /\.jpg$/, loader:'file-loader' }, { test: /\.s?css$/, // https://css-tricks.com/css-modules-part-2-getting-started/ // css?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5] loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader!sass-loader', }) } ] }, plugins: [ new webpack.optimize.CommonsChunkPlugin({name:'vendor', filename:'vendor.js'}), //export to global for bootstrap and etc. (needs jquery ^2.0) new webpack.ProvidePlugin({$: 'jquery', jQuery: 'jquery', 'window.jQuery': 'jquery'}), new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false, }, output: { comments: false, } }), // http://webpack.imtqy.com/docs/stylesheets.html // https://github.com/webpack/webpack/tree/master/examples/multiple-entry-points-commons-chunk-css-bundle new ExtractTextPlugin({filename: '[name].css'}), new webpack.LoaderOptionsPlugin({ debug: true, // test: /\.xxx$/, // may apply this only for some modules options: { // for @import path in the style file sassLoader: {includePaths: [path.resolve('./style') + '/']} } }), ] }; 

Any thoughts would be appreciated.

+3
babeljs webpack-2 webpack-dev-server
source share
1 answer

loaderUtils.parseQuery() used by loaders to get the parameters that are passed to the loader. It has been replaced by loaderUtils.getOptions() . You are probably using a loader that still uses parseQuery . All the loaders you use in your webpack configuration had to change to use getOptions , but you can use an older version that does not include the change. To fix this, you can simply upgrade your bootloaders to the latest version.

If for some reason you do not want to update all bootloaders, you can add the following line to the webpack configuration file (not as an option):

 process.traceDeprecation = true; 

This will give you a stack trace where parseQuery used, so you can identify the bootloader that actually uses it and update it.


It turns out that the latest babel-loader is still using parseQuery , it will be changed in the next major version and is already available in v7.0.0-alpha . But if you do not want to use the alpha version, you will have to live with a warning until v7.0.0 appears.

+8
source share

All Articles