postcss-assets icon indicating copy to clipboard operation
postcss-assets copied to clipboard

it seem like cant find file

Open cleverboy32 opened this issue 5 years ago • 12 comments

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 - -

cleverboy32 avatar Mar 04 '19 11:03 cleverboy32

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

borodean avatar Mar 04 '19 11:03 borodean

no . nothing console. it show Compiled successfully

cleverboy32 avatar Mar 04 '19 11:03 cleverboy32

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

borodean avatar Mar 04 '19 11:03 borodean

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

and real icon is this image

cleverboy32 avatar Mar 04 '19 11:03 cleverboy32

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

borodean avatar Mar 04 '19 11:03 borodean

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

cleverboy32 avatar Mar 04 '19 12:03 cleverboy32

What does the resulting CSS look like?

borodean avatar Mar 04 '19 12:03 borodean

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.

cleverboy32 avatar Mar 04 '19 12:03 cleverboy32

@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');

borodean avatar Mar 04 '19 14:03 borodean

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/']
        })
    ]
}

cleverboy32 avatar Mar 04 '19 14:03 cleverboy32

@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.

borodean avatar Mar 04 '19 20:03 borodean

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
        }),
    ]
};

cleverboy32 avatar Mar 05 '19 02:03 cleverboy32