如何解决如何在grunt-cli中提供外部端口,以便将其托管在服务器上?
我正在使用docker制作图像以运行前端。
它可以在笔记本电脑上完美运行,但是在服务器上,我无法通过浏览器访问它。
您可以查看我的屏幕截图,以查看我的浏览器在说些什么。
所以,我的项目在有角(grunt-cli)前端,后端在flask中,数据库是mongodb。 后端工作正常,但grunt-cli,我无法通过浏览器访问它,但我可以 卷曲http://:9000以查看内容。
这是我的Gruntfile.js-
module.exports = function(grunt) {
// ===========================================================================
// CONFIGURE GRUNT ===========================================================
// ===========================================================================
grunt.initConfig({
// get the configuration info from package.json ----------------------------
// this way we can use things like name and version (pkg.name)
pkg: grunt.file.readJSON('package.json'),// configure jshint to validate js files -----------------------------------
jshint: {
options: {
reporter: require('jshint-stylish')
},all: ['Grunfile.js','src/components/**/*.js']
},// configure uglify to minify js files -------------------------------------
uglify: {
options: {
banner: '/*\n <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> \n*/\n'
},build: {
files: {
'dist/js/components.min.js': 'src/components/**/*.js'
}
}
},// compile less stylesheets to css -----------------------------------------
less: {
build: {
files: {
'dist/css/pretty.css': 'src/css/pretty.less'
}
}
},// configure cssmin to minify css files ------------------------------------
cssmin: {
options: {
banner: '/*\n <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> \n*/\n'
},build: {
files: {
'dist/css/style.min.css': 'src/css/style.css'
}
}
},// configure watch to auto update ------------------------------------------
watch: {
stylesheets: {
files: ['src/**/*.css','src/**/*.less'],tasks: ['less','cssmin']
},scripts: {
files: 'src/**/*.js',tasks: ['jshint','uglify']
}
},express:{
all:{
options:{
port:9000,hostname:'0.0.0.0',bases:['./src'],livereload: true
}
}
}
});
// ===========================================================================
// LOAD GRUNT PLUGINS ========================================================
// ===========================================================================
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-express');
// ===========================================================================
// CREATE TASKS ==============================================================
// ===========================================================================
grunt.registerTask('serve-waalos',['jshint','cssmin','uglify','express','watch']);
grunt.registerTask('default',['test','build']);
};
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。