0

我已经让 Webpack 使用style-loaderand sass-loader,但无法弄清楚一件事:

我有两个单独的“样式表”包(我们的普通应用程序和客户端的自定义皮肤版本)。如果我单独需要它们,它仍然会以 1 个文件(bundle.css)的形式输出。我还尝试将 sass 源文件设置为入口点,但这给了我这个错误:

ERROR in Entry module not found: Error: Cannot resolve 'file' or 'directory' /Users/slangbroek/Projects/app-name/app/src/styles/mobile/mobile in /Users/slangbroek/Projects/app-name/app/src

对于两个样式表入口点。有谁知道如何使用 Webpack 完成此任务?

4

1 回答 1

0

You could use two .js entrypoints, one for the normal app and one for the custom-skinned version. If the only difference in these were the stylesheets, you may want to have 3 entrypoints, one for the app .js that both projects consume, and an entrypoint for each .scss file. All those entrypoint files would do is require the stylesheets.

Its pretty bizarre, but I believe that'd be the only pure webpack solution. Of course, you could consider using webpack in conjunction with gulp/grunt/etc, and use the task runner to bundle with webpack and compile your scss files as well.

于 2016-09-16T22:09:53.223 回答