borodean / postcss-assets

An asset manager for PostCSS
MIT License
537 stars 32 forks source link

it seem like cant find file #82

Open cleverboy32 opened 5 years ago

cleverboy32 commented 5 years ago

my config

require('postcss-assets')({
       loadPaths: ['../']
 }),

my css

src: resolve('fonts/som-ui-icons.woff?t=1472440741') format('woff'),
 resolve('fonts/som-ui-icons.ttf?t=1472440741') format('truetype');

it can complied and run, but my icon not found. i try some other features too , i aslo no use. why - -

borodean commented 5 years ago

@cleverboy32 do you observe any PostCSS-related errors in the console?

cleverboy32 commented 5 years ago

no . nothing console. it show Compiled successfully

borodean commented 5 years ago

@cleverboy32 how do you see that the icon is not found?

cleverboy32 commented 5 years ago

because the graph not show i use a star icon , but the render shape is a
image

and real icon is this image

borodean commented 5 years ago

@cleverboy32 but what about som-ui-icons.woff font itself? Is it being loaded? Because the problem might be with the font itself.

cleverboy32 commented 5 years ago

is i use this url('../../node_modules/@souche-ui/som-ui/src/styles/fonts/som-ui-icons.woff?t=1472440741') it can success.

and i use reslove ,try all the prossible path, but it just no error to log, so i cant konw why

borodean commented 5 years ago

What does the resulting CSS look like?

cleverboy32 commented 5 years ago

the css look like right image image

i cant see is the font file be loaded. the reason look like the file not be load.

borodean commented 5 years ago

@cleverboy32 what about this part? How does it look like in the compiled CSS?

src: resolve('fonts/som-ui-icons.woff?t=1472440741') format('woff'),
 resolve('fonts/som-ui-icons.ttf?t=1472440741') format('truetype');
cleverboy32 commented 5 years ago

oh, it still src: resolve(...) it not be parse.

my postcss.config.js and i use webpack

module.exports = {
    plugins: [
        require('postcss-assets')({
            loadPaths: ['../../node_modules/@souche-ui/som-ui/src/styles/']
        })
    ]
}
borodean commented 5 years ago

@cleverboy32 well, it does look to me that your file is not being processed by PostCSS at all.

By design, PostCSS Assets is never expected to keep those resolve functions intact. And if it can't resolve something an error should be thrown. Considering none of that happens I suspect that the problem is with the Webpack config itself, not with the PostCSS Assets.

Could you publish an example setup somewhere which I can use to reproduce the issue myself? I can try to help.

cleverboy32 commented 5 years ago

i did this. thank for you helping.

the post plugin i put it at the last step, and it will can parse. seem like it need the file convert totally, the plugin can Become effective。

module.exports = {
    plugins: [
        require('postcss-import')({
            resolve: createResolver({
                alias: {
                    'lemon': '@souche-ui/lemon',
                    'som-ui': '@souche-ui/som-ui'
                },
                modules: ['src', 'node_modules']
            })
        }),
        require('saladcss-bem')({
            defaultNamespace: 'som',
            separators: {
                descendent: "__"
            },
            shortcuts: {
                modifier: "m",
                descendent: "d",
                component: "c"
            }
        }),
        require('postcss-mixins'),
        require('precss'),
        require('postcss-shape'),
        require('postcss-utils'),
        require('postcss-preset-env')({
            stage: 0,
            browsers: ['ie > 8', 'iOS >= 7', 'Android >= 4.1', 'Safari >= 6']
        }),
        require('cssnano'),
        require('postcss-assets')({
            basePath: 'node_modules/@souche-ui/som-ui/src/styles',
            relative: true
        }),
    ]
};