Skip to content
Snippets Groups Projects
Commit cda2257c authored by Bastien Abadie's avatar Bastien Abadie
Browse files

Merge branch 'fix-production-build-css' into 'master'

Generate CSS files for production builds

Closes #951

See merge request !1236
parents bf3cb85b eef61bb2
No related branches found
No related tags found
1 merge request!1236Generate CSS files for production builds
const path = require('path')
const webpack = require('webpack')
const { merge } = require('webpack-merge')
const { mergeWithRules } = require('webpack-merge')
const { VueLoaderPlugin } = require('vue-loader')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
......@@ -151,6 +151,19 @@ const production = {
]
},
module: {
rules: [
{
test: /\.(sa|sc|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader'
]
}
]
},
plugins: [
// Remove previous build
new CleanWebpackPlugin(),
......@@ -197,6 +210,19 @@ const surge = {
]
},
module: {
rules: [
{
test: /\.(sa|sc|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader'
]
}
]
},
plugins: [
new webpack.EnvironmentPlugin({
// Use API Url provided by environment on surge
......@@ -215,6 +241,21 @@ const surge = {
]
}
/**
* Custom webpack merging that allows overriding a single rule
* without overriding all of module.rules.
* The correct rule to update will be matched using its `test` field
* and the `use` field will be replaced by whatever is set in the overrides.
*/
const merge = mergeWithRules({
module: {
rules: {
test: 'match',
use: 'replace'
}
}
})
module.exports = (env, args) => {
// webpack-cli only supports these 2 modes !
if (args.mode === 'production') {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment