javascript - SourceMapDevToolPlugin is working wierdly in webpack. It doesn't take over the devtool job -


when set both devtool:'source-map' , apply sourcemapdevtoolplugin , sourcemapdevtoolplugin doesn't take on devtool options , produce 2 different source maps.

the webpack.config.js:

const path = require('path'); const webpack = require('webpack'); const cleanwebpackplugin = require('clean-webpack-plugin'); const htmlwebpackplugin =  require('html-webpack-plugin');  var config = {     context: path.resolve( __dirname, 'src'),     entry:{         test1: 'test.js'     },     output: {         filename: 'js/[name].js?=[chunkhash]',         path: path.resolve( __dirname, 'dist'),         devtoolmodulefilenametemplate: '[absolute-resource-path]',         sourcemapfilename: 'srcmap/[file].map'     },     module: {         rules: [             {                 test: /\.jsx?$/,                 exclude: /node_modules/,                 use: [                     {                         loader: "babel-loader",                         options: {                             presets: ['es2015']                         }                     }                 ]             },             {                 test: /\.html$/,                 use: [ 'html-loader' ]             }         ]     },     plugins: [         new webpack.defineplugin({             'process.env': {                 node_env: json.stringify('production')             }         }),         new htmlwebpackplugin({             filename: 'html/index.html',             template: 'testsourcemap.html',             minify: {                 minifyjs: true,                 removecomments: true,                 sortattributes: true,             },             hash: false,             chunks: ['test1'],         }),         new webpack.optimize.uglifyjsplugin({             test: /\.js$/,             sourcemap: true,             uglifyoptions: {                 ie8: false,                 mangle: true,                 output: {                     comments: false,                     beautify: false,                 },                 compress: true,                 warnings: false             },             parallel: {                 cache: true,             }         }),         new webpack.sourcemapdevtoolplugin({              filename: 'srcmapplugin/[file].map',              include: ['js/test1.js'],              append: '\n//#sourcemappingurl=http://192.168.32.5:8080/[url]',              modulefilenametemplate:'[absolute-resource-path]',          }),         new cleanwebpackplugin([ 'dist/js', 'dist/srcmap', 'dist/srcmapplugin']),     ],     resolve: {         modules: ['src', "node_modules" ]     },     //devtool: process.env.node_env === 'production' ? 'source-map' :'cheap-module-eval-source-map'     devtool: 'source-map', };  console.log('now, node_env:', process.env.node_env); module.exports = config; 

and package.json:

{   "name": "srcmapplugin",   "version": "1.0.0",   "description": "",   "main": "index.js",   "scripts": {     "test": "echo \"error: no test specified\" && exit 1",     "v": ".\\node_modules\\.bin\\webpack -version",     "cd": ".\\node_modules\\.bin\\webpack  --optimize-minimize",     "cp": "cross-env node_env=production platform=web .\\node_modules\\.bin\\webpack --optimize-minimize"   },   "author": "",   "license": "isc",   "devdependencies": {     "babel": "^6.23.0",     "babel-core": "^6.26.0",     "babel-loader": "^7.1.2",     "babel-preset-env": "^1.6.0",     "babel-preset-es2015": "^6.24.1",     "clean-webpack-plugin": "^0.1.16",     "cross-env": "^5.0.5",     "html-loader": "^0.5.1",     "html-webpack-plugin": "^2.30.1",     "webpack": "^2.7.0"   } } 

after run command "npm run cp". 2 source map files in /dist/srcmap , /dist/srcmapplugin directories. furthermore doesn't work when browser html page. however, when delete "new webpack.sourcemapdevtoolplugin( { ... } ) " configuration. source map correctly working good!

how can devtool options , sourcemapdevtoolplugin options in webpack.config.js both produce source maps separately , result in broken source map ?

i suppose sourcemapdevtoolplugin overwrites options source map , produce 1 source map per js file.

the sample project in https://github.com/yincu/srcmapplugin.git

======================

i searched in google. tell me use either devtool or sourcemapdevtoolplugin. when use sourcemapdevtoolplugin, webpack still doesn't produce js source map, produces css source maps.


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -