Answer the question
In order to leave comments, you need to log in
How to split styles from one npm module?
There is a package (company-pack) in the local npm repository. Inside it has its own SASS grid and two versions: desktop.scss and mobile.scss, which collect different styles (this is important).
Method 1 works:
entry: {
desktop: './node_modules/company-pack/scss/desktop.scss',
mobile: './node_modules/company-pack/scss/mobile.scss'
},
module: {
rules: [
{
test: /\.js$/,
exclude: ['/node_modules/'],
use: [{
loader: 'babel-loader'
}]
},
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
sourceMap: true
}
},
{
loader:'sass-loader',
options: {
sourceMap: true
}
}
]
}
]
},
plugins: [
new FixStyleOnlyEntriesPlugin(),
new MiniCssExtractPlugin(is_production ? {
filename: 'css/[name].min.css',
chunkFilename: 'css/[name].min.css',
sourceMap: true,
} : {
filename: 'css/[name].css',
chunkFilename: 'css/[name].css',
sourceMap: false,
}),
]
entry: {
main: './main.js,
},
import { CssModules } from 'company-pack';
import Desktop from './scss/desktop.scss';
import Mobile from './scss/mobile.scss';
export default CssModules(Desktop, Mobile);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question