Skip to content

Commit 8eb7e1c

Browse files
LinusBorgchrisvfritz
authored andcommitted
Source maps option for vue css loaders (vuejs-templates#315)
* adding source map option to vue-loader's css loaders. * enable source maps for preprocessor loaders of vue-loader when config demands it. * use config.dev.env
1 parent d96fd80 commit 8eb7e1c

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

template/build/dev-server.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
var config = require('../config')
2+
if (!process.env.NODE_ENV) process.env.NODE_ENV = config.dev.env
13
var path = require('path')
24
var express = require('express')
35
var webpack = require('webpack')
4-
var config = require('../config')
56
var opn = require('opn')
67
var proxyMiddleware = require('http-proxy-middleware')
78
var webpackConfig = {{#if_or unit e2e}}process.env.NODE_ENV === 'testing'

template/build/utils.js

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ exports.cssLoaders = function (options) {
2525
return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : '')
2626
}).join('!')
2727

28+
// Extract CSS when that option is specified
29+
// (which is the case during production build)
2830
if (options.extract) {
2931
return ExtractTextPlugin.extract('vue-style-loader', sourceLoader)
3032
} else {

template/build/webpack.base.conf.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ var config = require('../config')
33
var utils = require('./utils')
44
var projectRoot = path.resolve(__dirname, '../')
55

6+
var env = process.env.NODE_ENV
7+
// check env & config/index.js to decide weither to enable CSS Sourcemaps for the
8+
// various preprocessor loaders added to vue-loader at the end of this file
9+
var cssSourceMapDev = (env === 'development' && config.dev.cssSourceMap)
10+
var cssSourceMapProd = (env === 'production' && config.build.productionSourceMap)
11+
var useCssSourceMap = cssSourceMapDev || cssSourceMapProd
12+
613
module.exports = {
714
entry: {
815
app: './src/main.js'
@@ -83,7 +90,7 @@ module.exports = {
8390
},
8491
{{/lint}}
8592
vue: {
86-
loaders: utils.cssLoaders(),
93+
loaders: utils.cssLoaders({ sourceMap: useCssSourceMap }),
8794
postcss: [
8895
require('autoprefixer')({
8996
browsers: ['last 2 versions']

0 commit comments

Comments
 (0)