Open Matmo10 opened 8 years ago
I got postcss working by using the following config for my production build, using following package versions:
{
"autoprefixer": "6.6.1",
"angular2-template-loader": "0.6.0",
"postcss-loader": "0.9.1",
"raw-loader": "0.5.1",
"webpack": "2.1.0-beta.27",
}
// necessary imports
const autoprefixer = require('autoprefixer');
const webpack = require('webpack');
const postcssDiscardComments = require('postcss-discard-comments');
// relevant rules
rules: [{
{
test: /\.css$/,
loaders: ['raw-loader', 'postcss-loader']
}, {
test: /.html$/,
loaders: [
'html-loader'
]
}]
// add to plugins array
new webpack.LoaderOptionsPlugin({
debug: false,
options: {
htmlLoader: {
// minimize: false // workaround for ng2
// see https://github.com/angular/angular/issues/10618#issuecomment-250322328
minimize: true,
removeAttributeQuotes: false,
caseSensitive: true,
customAttrSurround: [
[/#/, /(?:)/],
[/\*/, /(?:)/],
[/\[?\(?/, /(?:)/]
],
customAttrAssign: [/\)?\]?=/]
},
postcss: [
autoprefixer,
postcssDiscardComments
]
}
I'm trying to apply postcss plugins to the css files specified in my my styleUrl's via postcss-loader. Their project has the following example for webpack2 config:
My understanding of angular2-template-loader is that it basically turns
styleUrls: ['some-file.css']
intostyles: require('some.file.css')
, which ultimately gets handled by some css loader.Is that correct? The reason I'm questioning this is :
style-loader
withcss-to-string
loader in the config pasted above, but it doesn't seem to work (doesn't autoprefix the css)."The generated require statements", (for templateUrl and styleUrls), "will be handled by the given loader for .html and .js files"
. I would expect that to say "for .html and .css files". Does this mean that the styleUrl generates some sort of .js file which isn't handled by a .css loader?I asked about the setup on the postcss-loader repo (https://github.com/postcss/postcss-loader/issues/113) but they were understandably unfamiliar with this particular loader and how it should integrate with other loaders. Is there anything obviously wrong with my approach or understanding of how this loader works? Thanks!