var path = require('path');var webpack = require('webpack');module.exports = { entry :{ "index": "./src/index/main.js", //前台JS "admin": "./src/admin/main.js" //后台JS }, output: { path: path.resolve(__dirname, './dist'), publicPath: '/dist/', filename: '[name].js' }, module: { rules: [ { test: /\.vue$/, loader: 'vue-loader', options: { // vue-loader options go here } }, { test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ }, { test: /\.css$/, loader: 'style-loader!css-loader?root=../' }, { test: /\.(eot|svg|ttf|woff|woff2)$/, loader: 'file-loader' }, { test: /\.(png|jpe?g|gif|svg)(\?\S*)?$/, loader: 'file-loader', options: { name: '[name].[ext]?[hash]' } } ] }, resolve: { alias: { 'vue$': 'vue/dist/vue', } }, devServer: { historyApiFallback: true, noInfo: true }, plugins: [ new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }) ]};if (process.env.NODE_ENV === 'production') { module.exports.devtool = '#source-map'; // http://vue-loader.vuejs.org/en/workflow/production.html module.exports.plugins = (module.exports.plugins || []).concat([ new webpack.DefinePlugin({ 'process.env': { NODE_ENV: '"production"' } }), new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }), new webpack.LoaderOptionsPlugin({ minimize: true }) ])}
当webpack设置多入口且入口不在二级目录的时候(例如"./src/index/main.js"),css-loader则必须设置root 指向上一级目录即为../
暂时只能统一设置,当多入口不在同级目录有什么解决方式还未找到