webpack打包后,找不到angular state中templateUrl路径,该如何配置?

这是目录结构

图片说明

该文件为bike.js

angular.module('bike', ['ui.router', 'bike.services', 'oc.lazyLoad'])
.config(function ($stateProvider, $urlRouterProvider) {

    $stateProvider
        .state('map', {
            url: '/map',
            templateUrl: '../html/map.html',
            cache: false,
            controller: 'mapCtrl',
            resolve: {
                loadMyCtrl: function ($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        files: [
                            "../js/beforejs/map.js"
                        ]
                    })
                }
            }
        })

    $urlRouterProvider.otherwise('map');
})

.run(function ($rootScope, $templateCache) {
    $rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
        console.log(fromState.url)
        if (fromState.url == "/map") {
        clearInterval($rootScope.map_intervar)
           }
        if (typeof(toState) !== 'undefined' && toState.templateUrl) {
            $templateCache.remove(fromState.templateUrl);
        }
        $templateCache.removeAll();
    });
})

webpack.config.js

var HtmlWebpackPlugin = require("html-webpack-plugin");
var webpack = require("webpack");

module.exports = {
entry: {
// "vuedata":__dirname + "/public/js/vuedata.js",
"beforejs/bike":__dirname + "/public/js/beforejs/bike.js",
"beforejs/map":__dirname + "/public/js/beforejs/map.js",
"index":__dirname + "/public/js/index.js"
},
output: {
path: __dirname + "/public/webapp/js",
filename: "[name].js"
},
resolve: {
alias: {
vue:"vue/dist/vue.js"
}
},
module: {
loaders: [
{
test:/.js$/,
loader: "babel-loader"
}
]
},
plugins: [
new HtmlWebpackPlugin({
filename: __dirname+'/public/webapp/index.html',
template: __dirname+'/public/html/index.html',
inject:'body',
hash:true,
chunks:["beforejs/bike","index"]
}),
new HtmlWebpackPlugin({
filename: __dirname+'/public/webapp/html/map.html',
template: __dirname+'/public/html/map.html',
})
]
}

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐