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

fix postcss config #890

Merged
merged 5 commits into from
Nov 8, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Introduction

This boilerplate is targeted towards large, serious projects and assumes you are somewhat familiar with Webpack and `vue-loader`. Make sure to also read [`vue-loader`'s documentation](http://vuejs.github.io/vue-loader/index.html) for common workflow recipes.
This boilerplate is targeted towards large, serious projects and assumes you are somewhat familiar with Webpack and `vue-loader`. Make sure to also read [`vue-loader`'s documentation](https://vue-loader.vuejs.org/) for common workflow recipes.

If you just want to try out `vue-loader` or whip out a quick prototype, use the [webpack-simple](https://github.com/vuejs-templates/webpack-simple) template instead.

Expand Down
6 changes: 5 additions & 1 deletion template/build/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ exports.cssLoaders = function (options) {
}
}

var postcssLoader = {
loader: 'postcss-loader'
}

// generate loader string to be used with extract text plugin
function generateLoaders (loader, loaderOptions) {
var loaders = [cssLoader]
var loaders = options.usePostCSS !== false ? [cssLoader, postcssLoader] : [cssLoader]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Where does option.usePostCSS come from? It's not to be found in /config/index.js, not in any of the webpack config files. This should be documented someway.

Is the idea to simply add it to the styleLoader code like this?

// in webpack.base.conf.js:

rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true })

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the idea to simply add it to the styleLoader code like this?

// in webpack.base.conf.js:

rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true })

Yes, I think the usePostCSS config should be set in the webpack config file.

if (loader) {
loaders.push({
loader: loader + '-loader',
Expand Down
4 changes: 1 addition & 3 deletions template/build/webpack.base.conf.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var path = require('path')
var fs = require('fs')
var utils = require('./utils')
var config = require('../config')
var vueLoaderConfig = require('./vue-loader.conf')
Expand All @@ -26,8 +25,7 @@ module.exports = {
'vue$': 'vue/dist/vue.esm.js',
{{/if_eq}}
'@': resolve('src'),
},
symlinks: false
}
},
module: {
rules: [
Expand Down
2 changes: 1 addition & 1 deletion template/build/webpack.dev.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Object.keys(baseWebpackConfig.entry).forEach(function (name) {

module.exports = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true })
},
// cheap-module-eval-source-map is faster for development
devtool: '#cheap-module-eval-source-map',
Expand Down
3 changes: 2 additions & 1 deletion template/build/webpack.prod.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ var webpackConfig = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({
sourceMap: config.build.productionSourceMap,
extract: true
extract: true,
usePostCSS: true
})
},
devtool: config.build.productionSourceMap ? '#source-map' : false,
Expand Down