Why My Scss Files Generated Also .js extension? ( scss > css and js) #18488
Unanswered
cengizilhan
asked this question in
Q&A
Replies: 1 comment 1 reply
-
We generate it to undestand that the CSS chunk is loaded, but we prepare the new built-in CSS support out f box withoout extra generation |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello !
i have a webpack case. everything is good except just one thing.
for example
/styles/rapid.scss
exports like:
![screenshot attached](https://private-user-images.githubusercontent.com/15185676/338748191-d2ef0faf-d242-4a1c-9ebf-a056d95afe67.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAzMzg2NDYsIm5iZiI6MTcyMDMzODM0NiwicGF0aCI6Ii8xNTE4NTY3Ni8zMzg3NDgxOTEtZDJlZjBmYWYtZDI0Mi00YTFjLTllYmYtYTA1NmQ5NWFmZTY3LmpwZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA3VDA3NDU0NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPThiNTcwYWZkNDRkMmY4YzI0ZWFkNGNhMDliNTQ5YmRjNDRmMjcxNWU0MWVjNDg1MWE0YzE5M2ZlYzQ0MTU2YjkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.lDcvGxO-YdY5S6mHH7yB3qBfTKzie743VoY5Niv5Sjg)
/styles/rapid.css
/styles/rapid.js
i dont wanna js file for scss. there is any solution?
my webpack project: https://github.com/cengizilhan/webpack-test-2/
webpack common js
`const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const paths = require('./paths')
const glob = require('glob')
const path = require('path')
const TerserPlugin = require('terser-webpack-plugin')
// Find all .scss files
const scssFiles = glob.sync(paths.src + '/styles/**/*.scss', {
posix: true,
dotRelative: true
})
// Debugging: Log the found SCSS files
console.log('Found SCSS files:', scssFiles)
// Create an entry object for the SCSS files
const styleEntries = scssFiles.reduce((entries, filePath) => {
// Use the absolute path as the entry key
console.log('filePath', filePath)
console.log('entries', entries)
const entryKey = filePath
.replace('./Static/src/styles', './Static/styles')
.replace(/\/g, '/')
.replace('.scss', '')
}, {})
// Debugging: Log the generated style entries
console.log('Generated style entries:', styleEntries)
const scriptEntries = {
'./Static/scripts/aile/sawa.aile-app.min':
paths.src + '/scripts/aile/sawa.aile-app.js',
const styleTest = {
'/Static/style/sawa': paths.src + '/styles/sawa.scss'
}
// Merge entries
console.log('styleentiries', styleEntries)
console.log('scriptEntries', scriptEntries)
const entries = {
...styleEntries,
...scriptEntries,
//...styleTest
}
console.log('style test', styleTest)
module.exports = {
// Where webpack looks to start building the bundle
entry: entries,
optimization: {
minimize: true,
minimizer: [new TerserPlugin({
parallel: true,
extractComments: false,
terserOptions: {
nameCache: {},
safari10: true,
ie8: true,
sourceMap: true,
compress: {
drop_console: true,
},
},
})],
},/
/
watch:true,
watchOptions: {
aggregateTimeout: 300,
poll: 1000,
ignored: /node_modules/,
},
*/
// Customize the webpack build process
plugins: [
// Removes/cleans build folders and unused assets when rebuilding
new CleanWebpackPlugin(),
}`
webpack prod js
`const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
const { merge } = require('webpack-merge')
const paths = require('./paths')
const common = require('./webpack.common')
module.exports = merge(common, {
mode: 'production',
devtool: false,
output: {
path: paths.build,
publicPath: '/',
filename: '[name].js',
},
module: {
rules: [
{
test: /.(sass|scss|css)$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 2,
sourceMap: false,
modules: false,
},
},
'postcss-loader',
'sass-loader',
],
},
],
},
plugins: [
// Extracts CSS into separate files
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css',
}),
],
optimization: {
minimize: true,
minimizer: [new CssMinimizerPlugin(), '...'],
splitChunks: {
cacheGroups: {
styles: {
name: 'styles',
test: /.(sass|scss|css)$/,
//chunks: 'all',
enforce: true,
},
},
},
runtimeChunk: {
name: 'runtime',
},
},
performance: {
hints: false,
maxEntrypointSize: 512000,
maxAssetSize: 512000,
},
})`
Beta Was this translation helpful? Give feedback.
All reactions