Giter Club home page Giter Club logo

Comments (6)

JasonBoy avatar JasonBoy commented on May 31, 2024

你是怎么引入ant.css的,在哪里引入的

from koa-web-kit.

githen-cn avatar githen-cn commented on May 31, 2024

您好,我是用下面这种方法引入的

文件:src/page/hot/hot.js
引入 import "antd/dist/antd.css"

from koa-web-kit.

JasonBoy avatar JasonBoy commented on May 31, 2024

webpack.config.ssr.js 里面的externals里吧样式文件加入白名单试一下:

externals: [nodeExternals({
      whitelist: [/\.(sa|sc|c)ss$/],
    })],

from koa-web-kit.

githen-cn avatar githen-cn commented on May 31, 2024

您好,webpack.config.ssr.js配置为

const webpackConfig = webpackMerge(
{},
{
entry: {
ssr: utils.resolve('src/ssr/index.js'),
},
target: 'node',
mode: DEV_MODE ? 'development' : 'production',
output: {
path: utils.resolve('build/node'),
filename: '[name].js',
libraryExport: 'default',
libraryTarget: 'commonjs2',
},
externals: [nodeExternals({
whitelist: [/.(sa|sc|c)ss$/],
})],
resolve: {
...utils.getWebpackResolveConfig(),
},
module: {
rules: [
utils.getBabelLoader(true),
...utils.getAllStyleRelatedLoaders(
DEV_MODE,
false,
false,
undefined,
true
),
utils.getImageLoader(DEV_MODE, APP_PATH),
utils.getMediaLoader(DEV_MODE, APP_PATH),
],
},
plugins: [
new webpack.DefinePlugin({
isBrowser: false,
pathPrefix: JSON.stringify(prefix),
}),
new webpack.LoaderOptionsPlugin({
debug: DEV_MODE,
minimize: !DEV_MODE,
options: {
context: APP_PATH,
},
}),
// new MiniCssExtractPlugin({
// filename: "[name].css",
// chunkFilename: "[id].css"
// }),
],
}
);

还是有报错,报错信息如下:

$ npm run dev:ssr

[email protected] dev:ssr /home/code
cross-env ENABLE_HMR=0 CSS_MODULES=0 ENABLE_SSR=1 npm-run-all -p watch watch:ssr start

[email protected] watch /home/code
webpack --watch --progress --hide-modules --config config/webpack.config.dev.js

[email protected] watch:ssr /home/code
npm run ssr -- --watch

[email protected] start /home/code
nodemon --trace-warnings server.js

[email protected] ssr /home/code
webpack --progress --config config/webpack.config.ssr.js "--watch"

[nodemon] 1.18.10
[nodemon] to restart at any time, enter rs
[nodemon] watching: /home/code/api//* /home/code/config//* /home/code/build/node//* /home/code/routes//* /home/code/utils//* /home/code/services//* app-config.js server.js
[nodemon] starting node --trace-warnings server.js
Using [/home/code/config/app-config.js] as basic app configuration
Using [/home/code/config/app-config.js] as basic app configuration
Using [/home/code/config/app-config.js] as basic app configuration
10% building 0/0 modules 0 active
webpack is watching the files…

(node:58140) DeprecationWarning: Tapable.plugin is deprecated. Use new API on .hooks instead
10% building 0/1 modules 1 active .../app/spa/code/pc_koa_2.8.2/src/index.js 10% building 0/0 modules 0 active
webpack is watching the files…

11% building 9/13 modules 4 active ...@load 10% building 1/2 modules 1 active .../runtime/helpers/interopR 11% building 10/13 modules 3 active ...@loadable/component/dist/loadable.es.js 10% building 2/2 modules 0 11% building 11/13 modules 2 active ...@load 10% building 8/9 modules 1 active ...de/pc_koa_2.8.2/build/ap 11% building 14/36 modules 22 active ...spa 11% building 13/14 modules 1 active ...ool/schoolInfo/schoolHo 14% building 35/70 modules 35 active ...ages/School/schoolInfo/stuPlan/index.js 13% building 30/39 modules 21% building 93/125 modules 32 active ...l/schoolInfo/schoolHome/schoolHome.scss/home/code/node_modules/antd/dist/antd.css:15
body {
^

SyntaxError: Unexpected token {
at new Script (vm.js:83:7)
at createScript (vm.js:267:10)
at Object.runInThisContext (vm.js:319:10)
at Module._compile (internal/modules/cjs/loader.js:684:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Module.require (internal/modules/cjs/loader.js:657:17)
at require (internal/modules/cjs/helpers.js:22:18)
[nodemon] app crashed - waiting for file changes before starting...

21% building 93/147 modules 54 active ...es/School/schoolInfo/baosong/index.scss 23% building 112/166 modu
24% building 118/168 modules 50 active ...8.2/node_modules/object-assign/index.js 23% building 109/167 mod
26% building 136/174 modules 38 active ...School/schoolInfo/professional/index.js 24% building 123/182 mod
26% building 136/176 modules 40 active ...2/src/components/schoolInfo/schoolAd.js 24% building 124/182 mod
27% building 149/193 modules 44 active ...ol/schoolInfo/yuanxi/yuanxiContent.scss

from koa-web-kit.

JasonBoy avatar JasonBoy commented on May 31, 2024

用这个branch试一下,我试了下是可以的 https://github.com/JasonBoy/koa-web-kit/tree/issue%2325-demo
wx20190222-150611 2x

from koa-web-kit.

githen-cn avatar githen-cn commented on May 31, 2024

这个可以正常编译了,十分感谢

from koa-web-kit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.