I get this error whenever running my build.
Invalid CSS after "module.exports": expected "{", was '= "data:text/x-scss'
I've also tried using a vanilla JS webpack config and get the same error, so it's not the TypeScript config. Also tried extract-text-webpack-plugin but get the same error. The actual app is working fine, but obviously has no CSS. Here is the config.
import * as path from 'path';
import * as webpack from 'webpack'
const config: webpack.Configuration = {
entry: {
app: ['./js/main.ts']
},
output: {
path: path.resolve(__dirname, './dist/js'),
filename: '[name].js'
},
module: {
rules:[
{
test: /\.html$/,
loader: 'ngtemplate-loader?prefix=/&module=app&relativeTo=' + (path.resolve(__dirname, './js/app')) + '/!html-loader'
},
{
test: /\.ts$/,
loader: 'awesome-typescript-loader'
},
{
test: /\.(sass|scss|ttf|svg|woff)$/,
use: [{
loader: "style-loader"
}, {
loader: "css-loader"
}, {
loader: "sass-loader",
}, {
loader: "url-loader"
}]
}
]
}
}
export default config
And here is the snippet of the main sass file.
@import "utilities/variables";
@import "utilities/animations";
@import "utilities/helpers";
Which is imported in the main app file with:
import '../sass/sass.scss';
I think the error is because you use url-loader
for Sass
files somehow. Split your webpack.config rule for (sass|scss|ttf|svg|woff)
so it looks like this:
{
test: /\.(ttf|svg|woff)$/,
use: [{
loader: "url-loader"
}]
},
{
test: /\.(sass|scss)$/,
use: [{
loader: "style-loader"
}, {
loader: "css-loader"
}, {
loader: "sass-loader",
}]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With