猿问

如何使用已转译的吞咽“主.js”

我是Angularjs 1.0的初学者,我的脚本不起作用,所以我曾经使用下面的代码将ec6编译为ec5。我能够建造它并制作.启动应用程序时如何连接它? 不工作。gulpmain.jsnpm related commands


我正在使用MVC5作为后端,所以我只需启动它,然后我可以看到项目的进展。


如何使用来启动应用程序或调试应用程序?main.js


'use strict';


const gulp = require('gulp');

const browserSync = require('browser-sync').create();

const sass = require('gulp-sass');

const autoprefixer = require('gulp-autoprefixer');

const livereload = require('gulp-livereload');

const concat = require('gulp-concat');


gulp.task('scripts', function () {

    return gulp.src('./Scripts/**/*.js')

        .pipe(concat('main.js'))  

        .pipe(gulp.dest('build/js'));

});





// Compile Sass & Inject Into Browser

gulp.task('sass', function () {

    return gulp.src(['./Content/scss/*.scss'])

        .pipe(sass())

        .pipe(autoprefixer({

            browsers: ['last 2 versions'],

            cascade: false

        }))

        .pipe(gulp.dest("./Content"))

        .pipe(livereload());

});


// Watch Sass & Serve

gulp.task('serve', ['sass'], function () {

    gulp.watch(['./Content/scss/*.scss'], ['sass']);

});


// Default Task

gulp.task('default', ['serve', 'scripts','sass']);


牧羊人nacy
浏览 70回答 1
1回答

芜湖不芜

我在Django框架中这样做了,如下所示:索引.html{% if load_minified_scripts %}&nbsp; &nbsp;<script src="{% static "minified_assets/js/site.min.js" %}"></script>{% else %}&nbsp; &nbsp;<script src="{% static "script/app.js" %}"></script>&nbsp; &nbsp;<script src="{% static "script/controller.js" %}"></script>{% endif %}这是从服务器端设置的。load_minified_scriptsviews.py@csrf_protect@requires_csrf_tokendef index(request):&nbsp; &nbsp; if request.session.session_key is None:&nbsp; &nbsp; &nbsp; &nbsp; request.session['has_session'] = True&nbsp; &nbsp; &nbsp; &nbsp; request.session.modified = True&nbsp; &nbsp; return render(request, 'index.html', {'user': request.user,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'debug': settings.DEBUG,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'session_key': request.session.session_key,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "load_minified_scripts": settings.LOAD_MINIFIED_SCRIPTS}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , content_type="text/html")根据 ,得到它的值。对于环境来说,它是。envsettings.LOAD_MINIFIED_SCRIPTSDEVfalse同样,您也可以为其他语言执行此操作。
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答