Skip to content

Commit 5b59095

Browse files
committed
make sourcemaps editable in config
also reorganize the config file a bit.
1 parent 5078199 commit 5b59095

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

template/build/webpack.dev.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const devWebpackConfig = merge(baseWebpackConfig, {
1313
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true })
1414
},
1515
// cheap-module-eval-source-map is faster for development
16-
devtool: '#cheap-module-eval-source-map',
16+
devtool: config.dev.devtool,
1717

1818
// these devServer options should be customized in /config/index.js
1919
devServer: {

template/build/webpack.prod.conf.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const webpackConfig = merge(baseWebpackConfig, {
2222
usePostCSS: true
2323
})
2424
},
25-
devtool: config.build.productionSourceMap ? '#source-map' : false,
25+
devtool: config.build.productionSourceMap ? config.build.devtool : false,
2626
output: {
2727
path: config.build.assetsRoot,
2828
filename: utils.assetsPath('js/[name].[chunkhash].js'),
@@ -38,7 +38,7 @@ const webpackConfig = merge(baseWebpackConfig, {
3838
compress: {
3939
warnings: false
4040
},
41-
sourceMap: true,
41+
sourceMap: config.build.productionSourceMap,
4242
parallel: true
4343
}),
4444
// extract css into its own file

template/config/index.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ const path = require('path')
66

77
module.exports = {
88
dev: {
9-
host: 'localhost', // can be overwritten by process.env.HOST
10-
port: 8080, // can be overwritten by process.env.HOST, if port is in use, a free one will be determined
119

1210
// Paths
1311
assetsSubDirectory: 'static',
1412
assetsPublicPath: '/',
1513
proxyTable: {},
1614

1715
// Various Dev Server settings
16+
host: 'localhost', // can be overwritten by process.env.HOST
17+
port: 8080, // can be overwritten by process.env.HOST, if port is in use, a free one will be determined
1818
autoOpenBrowser: false,
1919
errorOverlay: true,
2020
notifyOnErrors: true,
@@ -28,18 +28,26 @@ module.exports = {
2828
// in the browser.
2929
showEslintErrorsInOverlay: false,
3030

31-
// CSS Sourcemaps off by default because relative paths are "buggy"
32-
// with this option, according to the CSS-Loader README
33-
// (https://github.com/webpack/css-loader#sourcemaps)
34-
// In our experience, they generally work as expected,
35-
// just be aware of this issue when enabling this option.
36-
cssSourceMap: false,
31+
/**
32+
* Source Maps
33+
*/
34+
35+
// https://webpack.js.org/configuration/devtool/#development
36+
devtool: 'eval-source-map',
3737

3838
// If you have problems debugging vue-files in devtools,
3939
// set this to false - it *may* help
4040
// https://vue-loader.vuejs.org/en/options.html#cachebusting
4141
cacheBusting: true,
42+
43+
// CSS Sourcemaps off by default because relative paths are "buggy"
44+
// with this option, according to the CSS-Loader README
45+
// (https://github.com/webpack/css-loader#sourcemaps)
46+
// In our experience, they generally work as expected,
47+
// just be aware of this issue when enabling this option.
48+
cssSourceMap: false,
4249
},
50+
4351
build: {
4452
// Template for index.html
4553
index: path.resolve(__dirname, '../dist/index.html'),
@@ -49,19 +57,24 @@ module.exports = {
4957
assetsSubDirectory: 'static',
5058
assetsPublicPath: '/',
5159

60+
/**
61+
* SourceMap
62+
*/
5263
productionSourceMap: true,
64+
// https://webpack.js.org/configuration/devtool/#production
65+
devtool: '#source-map',
66+
5367
// Gzip off by default as many popular static hosts such as
5468
// Surge or Netlify already gzip all static assets for you.
5569
// Before setting to `true`, make sure to:
5670
// npm install --save-dev compression-webpack-plugin
57-
5871
productionGzip: false,
5972
productionGzipExtensions: ['js', 'css'],
73+
6074
// Run the build command with an extra argument to
6175
// View the bundle analyzer report after build finishes:
6276
// `npm run build --report`
6377
// Set to `true` or `false` to always turn it on or off
64-
6578
bundleAnalyzerReport: process.env.npm_config_report
6679
}
6780
}

0 commit comments

Comments
 (0)