ivew自定义主题出错


64x64
匿名 2017-11-01 17:21 564

按照官方指导的配置, my-theme 下建立一个 less 文件 index.less,并写入下面内容:

@import '~iview/src/styles/index.less';

// 下面是要覆盖的变量,例如:
@primary-color: #8c0776;

然后在入口文件 main.js 内导入这个 less 文件即可:

import Vue from 'vue';
import iView from 'iview';
import '../my-theme/index.less';

Vue.use(iView);

出现错误,提示如下:

ERROR in ../my-theme/index.less Module build failed: ModuleParseError: Module parse failed:
    E:\work\iview-admin-dev\node_modules\autoprefixer-loader\index.js!
    E:\work\iview-admin-dev\node_modules\less-loader\index.js!
    E:\work\iview-admin-dev\src\sty les\index.less Unexpected token (1:0) You may need an appropriate loader to handle this file type. | .ivu-load-loop { | -webkit-animation: ani-load-loop 1s linear infinite; | animation: ani-load-loop 1s linear infinite; at doBuild.e (E:\work\iview-admin-dev\node_modules\webpack\lib\NormalModule.js:296:19) at runLoaders (E:\work\iview-admin-dev\node_modules\webpack\lib\NormalModule.js:206:11) at E:\work\iview-admin-dev\node_modules\loader-runner\lib\LoaderRunner.js:370:3 at iterateNormalLoaders (E:\work\iview-admin-dev\node_modules\loader-runner\lib\LoaderRunner.js:211:10) at iterateNormalLoaders (E:\work\iview-admin-dev\node_modules\loader-runner\lib\LoaderRunner.js:218:10) at E:\work\iview-admin-dev\node_modules\loader-runner\lib\LoaderRunner.js:233:3 at Object.context.callback (E:\work\iview-admin-dev\node_modules\loader-runner\lib\LoaderRunner.js:111:13) at Object.module.exports (E:\work\iview-admin-dev\node_modules\autoprefixer-loader\index.js:55:10) @ ./src/main.js 43:0-30 @ multi (webpack)-dev-server/client?http://localhost:9000 webpack/hot/dev-server ./src/main ERROR in ../my-theme/index.less Module build failed: ModuleParseError: Module parse failed:
    E:\work\iview-admin-dev\node_modules\autoprefixer-loader\index.js!
    E:\work\iview-admin-dev\node_modules\less-loader\index.js!
    E:\work\iview-admin-dev\src\sty les\index.less Unexpected token (1:0) You may need an appropriate loader to handle this file type. | .ivu-load-loop { | -webkit-animation: ani-load-loop 1s linear infinite; | animation: ani-load-loop 1s linear infinite; at doBuild.e (E:\work\iview-admin-dev\node_modules\webpack\lib\NormalModule.js:296:19) at runLoaders (E:\work\iview-admin-dev\node_modules\webpack\lib\NormalModule.js:206:11) at E:\work\iview-admin-dev\node_modules\loader-runner\lib\LoaderRunner.js:370:3 at iterateNormalLoaders (E:\work\iview-admin-dev\node_modules\loader-runner\lib\LoaderRunner.js:211:10) at iterateNormalLoaders (E:\work\iview-admin-dev\node_modules\loader-runner\lib\LoaderRunner.js:218:10) at E:\work\iview-admin-dev\node_modules\loader-runner\lib\LoaderRunner.js:233:3 at Object.context.callback (E:\work\iview-admin-dev\node_modules\loader-runner\lib\LoaderRunner.js:111:13) at Object.module.exports (E:\work\iview-admin-dev\node_modules\autoprefixer-loader\index.js:55:10) Child html-webpack-plugin for "..\index.html": chunk {0} ../index.html 542 kB [entry]
iviewstructvue 回答问题

2 个解决方案


1
匿名 2017-11-01T17:25:10

在webpack.base.config.js文件,配置

{
    test: /\.less/,
    use: ExtractTextPlugin.extract({
        use: ['css-loader?minimize','autoprefixer-loader', 'less-loader'],
        fallback: 'style-loader'
    })
}

默认生成的是没有‘'css-loader?minimize'’这一条,加上后再启动就没问题了


2
Albee 2017-10-31T23:09:52

tomcat没有把jar包拷贝到运行环境,是因为我们在配置tomcat的时候选择了“调试模式”,即“debug”;需设置为“生产模式”,即“run”,之后重新部署即可。
模式设置位置:myeclipse--preferences--servers--tomcatxx--launch选择“run mode”。  


评论