Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

问一下png格式的icon怎么处理 #38

Closed
w0330t opened this issue Sep 21, 2019 · 6 comments
Closed

问一下png格式的icon怎么处理 #38

w0330t opened this issue Sep 21, 2019 · 6 comments

Comments

@w0330t
Copy link

w0330t commented Sep 21, 2019

项目中的icon都是png,我原本打算放在assets的icon里面,但是又发现该目录不会编译进入dist,所以问一下这个怎么处理。另外建立一个icon目录吗?
还有一个事,我写了个scss的公共函数,本来想放utils里,结果发现导入的时候编译器找不到,然后我看见assets里面写着可以放scss组件,我又放到assets里面,结果编译依然报错。

@w0330t
Copy link
Author

w0330t commented Sep 21, 2019

我接着尝试,发现scss放在utils里面被编译成了wxss,

@NewFuture
Copy link
Owner

图标是使用image还是嵌入的背景图?
如果直接使用图片的话建个image的文件夹即可

assets 文件夹(可以配置)默认是放一些开发的时候用到,编译之后就没有的文件
比如公共的scss或者内联的背景图文件。

需要注意一下引用文件路径

@NewFuture
Copy link
Owner

编译报错可以贴一下代码和错误信息

@w0330t
Copy link
Author

w0330t commented Sep 21, 2019

我导入的文件是这个sass-rpx
因为用的webstorm而且scss一直都报rpx的错
然后报错如下


[23:43:31] 4wxss > app.scss → app.wxss
[23:43:31] 5json > app.jsonc → app.json
[23:43:31] 4wxss [×] Error
src\app.scss
Error: Can't find stylesheet to import.
  ╷
1 │ @import "/assets/rpx";
  │         ^^^^^^^^^^^^^
  ╵
  src\app.scss 1:9  root stylesheet
src\app.scss
Error: src\app.scss
Error: Can't find stylesheet to import.
  ╷
1 │ @import "/assets/rpx";
  │         ^^^^^^^^^^^^^
  ╵
  src\app.scss 1:9  root stylesheet
    at Object._newRenderError (Y:\clustered\node_modules\sass\sass.dart.js:10748:19)
    at Object._wrapException (Y:\clustered\node_modules\sass\sass.dart.js:10598:16)
    at _render_closure1.call$2 (Y:\clustered\node_modules\sass\sass.dart.js:33339:21)
    at _RootZone.runBinary$3$3 (Y:\clustered\node_modules\sass\sass.dart.js:19690:18)
    at _RootZone.runBinary$3 (Y:\clustered\node_modules\sass\sass.dart.js:19694:19)
    at _FutureListener.handleError$1 (Y:\clustered\node_modules\sass\sass.dart.js:18159:19)
    at _Future__propagateToListeners_handleError.call$0 (Y:\clustered\node_modules\sass\sass.dart.js:18447:40)
    at Object._Future__propagateToListeners (Y:\clustered\node_modules\sass\sass.dart.js:3484:88)
    at _Future._completeError$2 (Y:\clustered\node_modules\sass\sass.dart.js:18283:9)
    at _AsyncAwaitCompleter.completeError$2 (Y:\clustered\node_modules\sass\sass.dart.js:17682:12)
Error in plugin "sass"
Message:
    src\app.scss
Error: Can't find stylesheet to import.
  ╷
1 │ @import "/assets/rpx";
  │         ^^^^^^^^^^^^^
  ╵
  src\app.scss 1:9  root stylesheet
Details:
    formatted: Error: Can't find stylesheet to import.
  ╷
1 │ @import "/assets/rpx";
  │         ^^^^^^^^^^^^^
  ╵
  src\app.scss 1:9  root stylesheet
    line: 1
    column: 9
    file: Y:\clustered\src\app.scss
    status: 1
    messageFormatted: src\app.scss
Error: Can't find stylesheet to import.
  ╷
1 │ @import "/assets/rpx";
  │         ^^^^^^^^^^^^^
  ╵
  src\app.scss 1:9  root stylesheet
    messageOriginal: Can't find stylesheet to import.
  ╷
1 │ @import "/assets/rpx";
  │         ^^^^^^^^^^^^^
  ╵
  src\app.scss 1:9  root stylesheet
    relativePath: src\app.scss

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! clustered@1.0.0 start: `mp`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the clustered@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Blueness\AppData\Roaming\npm-cache\_logs\2019-09-21T15_43_31_279Z-debug.log

Process finished with exit code 1

这里是引用代码,我不调用这个,光引用就报错

@import "/assets/rpx";

text {
    font-size: 30rpx;
	color: #666;
}

page {
	background-color: #f5f5f5;
	min-height: 100%;
	display: flex;
	flex-direction: column;
}

@import "/assets/rpx";

text {
    font-size: 30rpx;
	color: #666;
}

page {
	background-color: #f5f5f5;
	min-height: 100%;
	display: flex;
	flex-direction: column;
}

我尝试把上面的_rpx.scss名字改为rpx.scss,也是不行的

@NewFuture
Copy link
Owner

NewFuture commented Sep 21, 2019

scss 这个不支持绝对路径

@import "./assets/rpx";
// 或者
@import "rpx";

PS: 这个用VScode 装上插件 完全是另一种体验

如果需要支持 / 更目录引用 可以 在 https://github.com/NewFuture/miniprogram-build/issues 开一个讨论一下

@w0330t
Copy link
Author

w0330t commented Sep 21, 2019

好的谢谢,我试试vscode

@w0330t w0330t closed this as completed Sep 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants