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

feat: added sass config to webpack server config #58

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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 package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "voltranjs",
"version": "1.1.11",
"version": "1.1.11-beta.0",
"main": "src/index.js",
"author": "Hepsiburada Technology Team",
"bin": {
Expand Down
66 changes: 53 additions & 13 deletions webpack.server.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const webpack = require('webpack');
const {merge} = require('webpack-merge');
const nodeExternals = require('webpack-node-externals');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');


const env = process.env.VOLTRAN_ENV || 'local';

Expand Down Expand Up @@ -64,9 +66,37 @@ const serverConfig = merge(commonConfig, voltranServerConfig, {
multiple: [...replaceString()],
},
},
{
test: /\.css$/,
use: [
isDebug
? {
loader: "style-loader",
options: {
injectType: "singletonStyleTag"
}
}
: MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
modules: false,
importLoaders: 1,
sourceMap: isDebug
}
},
{
loader: "postcss-loader",
options: postCssConfig
}
]
},
{
test: /\.scss$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: 'css-loader',
options: {
Expand All @@ -75,31 +105,36 @@ const serverConfig = merge(commonConfig, voltranServerConfig, {
? `${voltranConfig.prefix}-[name]-[hash:base64]`
: `${voltranConfig.prefix}-[path][name]__[local]`,
localIdentHashSalt: packageJson.name,
exportOnlyLocals: true,
},
importLoaders: 1,
importLoaders: 2,
sourceMap: isDebug,
}
},
},
{
loader: 'postcss-loader',
options: postCssConfig
options: postCssConfig,
},
{
loader: 'sass-loader',
options: {
implementation: require('sass'),
sassOptions: {
outputStyle: 'compressed',
},
},
},
...(voltranConfig.sassResources
? [
{
loader: 'sass-resources-loader',
options: {
sourceMap: false,
resources: voltranConfig.sassResources,
{
loader: 'sass-resources-loader',
options: {
sourceMap: false,
resources: voltranConfig.sassResources,
},
},
},
]
: [])
]
]
: []),
],
}
]
},
Expand All @@ -120,6 +155,11 @@ const serverConfig = merge(commonConfig, voltranServerConfig, {
__DEV__: isDebug,
}),

new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: "[id]-[contenthash].css"
}),

...(isDebug ? [new webpack.HotModuleReplacementPlugin()] : [])
]
});
Expand Down