Skip to content
Merged
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
33 changes: 17 additions & 16 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,28 @@ export default function loader(content, map, meta) {
const sourceMap = options.sourceMap || false;
const plugins = [];

if (shouldUseModulesPlugins(options.modules, this.resourcePath)) {
plugins.push(...getModulesPlugins(options, this));
}

const exportType = options.onlyLocals ? 'locals' : 'full';
const preRequester = getPreRequester(this);
const urlHandler = (url) =>
stringifyRequest(this, preRequester(options.importLoaders) + url);
const icssResolver = this.getResolve({
mainFields: ['css', 'style', 'main', '...'],
mainFiles: ['index', '...'],
});

plugins.push(
icssParser({
context: this.context,
rootContext: this.rootContext,
resolver: icssResolver,
urlHandler,
})
);
if (shouldUseModulesPlugins(options.modules, this.resourcePath)) {
plugins.push(...getModulesPlugins(options, this));

const icssResolver = this.getResolve({
mainFields: ['css', 'style', 'main', '...'],
mainFiles: ['index', '...'],
});

plugins.push(
icssParser({
context: this.context,
rootContext: this.rootContext,
resolver: icssResolver,
urlHandler,
})
);
}

if (options.import !== false && exportType === 'full') {
const resolver = this.getResolve({
Expand Down
4 changes: 3 additions & 1 deletion test/icss.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const testCases = fs.readdirSync(testCasesPath);
describe('ICSS', () => {
testCases.forEach((name) => {
it(`show work with the case "${name}"`, async () => {
const compiler = getCompiler(`./icss/tests-cases/${name}/source.js`);
const compiler = getCompiler(`./icss/tests-cases/${name}/source.js`, {
modules: 'global',
});
const stats = await compile(compiler);

expect(
Expand Down