MPA JS CSS预处理方案
1、WebPack
添加配置文件webpack.config.js,直接在当前目录运行 webpack。
var basepath = '/root/webapps/happ'; var glob = require('glob'); var entries = getEntry('./Views/**/*.js'); // 获得入口js文件 function getEntry(globPath) { var entries = {}; glob.sync(globPath).forEach(function (entry) { if (entry.endsWith('.min.js')) { return true; } console.log(entry) var pathname = entry.substring(0, entry.length - 3); entries[pathname] = entry; }); console.log(entries) return entries; } module.exports = { entry: entries, output: { filename: '[name].min.js' } //resolve: { alias: { 'vue': basepath+'/node_modules/vue/dist/vue.js' } } };
2、Web Complier
安装好VS插件后,在工程上右键,选择web complier ---> enble on build 。发布时自动压缩。