【问题标题】:How to enable browserify with grunt for jquery-ui如何使用 grunt 为 jquery-ui 启用 browserify
【发布时间】:2016-10-25 08:09:57
【问题描述】:

我来了

"Error: Cannot find module './core' from '/var/www/html/psychedharma/public_html/vendor'"

我通常不使用 browserify,但 jquery-ui 似乎需要它(请原谅双关语。)

非常感谢任何帮助。

module.exports = function(grunt) {

    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-browserify');

    grunt.initConfig({

        node: './node_modules',
        dest: './public_html/vendor',
        destfaf: './public_html/fonts',

        copy: {
            main: {
                files: [                    
                    {
                        expand: true,
                        flatten: true,
                        src: ['<%= node %>/font-awesome/fonts/fontawesome-webfont.*'],
                        dest: '<%= destfaf %>/', 
                        filter: 'isFile'
                    },
                    {
                        expand: true,
                        flatten: true,
                        src: ['<%= node %>/bootstrap/fonts/glyphicons-halflings-regular.*'],
                        dest: '<%= destfaf %>/', 
                        filter: 'isFile'
                    }
                ]
            }
        },
        concat: {           
            css: {
                files: {
                    '<%= dest %>/css.css': [
                        '<%= node %>/bootstrap/dist/css/bootstrap.min.css',
                        '<%= node %>/font-awesome/css/font-awesome.min.css'
                    ]
                }
            },
            js: {
                files: {
                    '<%= dest %>/js.js': [
                        '<%= node %>/jquery/dist/jquery.min.js',
                        '<%= node %>/bootstrap/dist/js/bootstrap.min.js',
                        '<%= node %>/less/dist/less.min.js',
                        '<%= node %>/jquery-ui/jquery-ui.js',
                        '<%= node %>/jquery-ui/sortable.js'
                    ]
                }
            }
        },
        browserify: {
            dist: {
                files: {
                    '<%= dest %>/js.js': ['<%= dest %>/js.js']
                },
                // options: {
                //     transform: ['coffeeify']
                // }   
            }
        },
        uglify: {
            build: {
                files: {
                    '<%= dest %>/js.min.js': [ '<%= dest %>/js.js' ]
                }
            }
        }
    });

    grunt.registerTask('def', [
        'concat',
        'copy',
        'browserify',
        'uglify'
    ]);

    grunt.registerTask('default', ['def']);
};

【问题讨论】:

    标签: javascript jquery-ui npm gruntjs browserify


    【解决方案1】:

    好的,我找到了解决办法。

    首先我使用了官方 repo 中的 jquery UI 标签:

    npm install --save github:jquery/jquery-ui#1.11.4
    

    然后我替换了这些行:

    '<%= node %>/jquery-ui/jquery-ui.js',
    '<%= node %>/jquery-ui/sortable.js'
    

    与:

    '<%= node %>/jquery-ui/ui/core.js',
    '<%= node %>/jquery-ui/ui/widget.js',
    '<%= node %>/jquery-ui/ui/mouse.js',
    '<%= node %>/jquery-ui/ui/sortable.js'  
    

    看来 browserify 根本就不需要了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多