vue路由require方法_不用vuejs的路由懒加载,直接用require引入文件,为什么不起作用?能帮忙解决吗...

const path = require('path')

const HTMLPlugin = require('html-webpack-plugin')

const webpack = require('webpack')

const ExtractPlugin = require('extract-text-webpack-plugin')

const fs = require('fs');

const mainFile = 'index.js';

const isDev = process.env.NODE_ENV === 'development'

const srcRoot = path.resolve(__dirname, 'src');

const config = {

target: 'web',

entry: path.join(__dirname, 'src/main.js'),

output: {

filename: 'pk-skin.min.js',

path: path.join(__dirname, 'dev')

},

resolve: {

alias: {

components: path.resolve(srcRoot, 'components'),

"@": path.resolve(srcRoot),

"vue$": 'vue/dist/vue.esm.js'

},

extensions: ['*', '.js', '.vue', '.json']

},

devServer: {

port: 8001,

host: '127.0.0.1',

overlay: {

errors: true,

},

// historyApiFallback: {

//     index: '/public/index.html'

// },

hot: true

},

module: {

rules: [

{

test: /\.vue$/,

loader: 'vue-loader'

},

{

test: /\.(js|jsx)$/,

loader: 'babel-loader',

exclude: /node_modules/

},

{

test: /\.less$/,

loader: "style-loader!css-loader!less-loader",

},

{

test: /\.css$/,

loader: "style-loader!css-loader",

},

{

test: /\.(ttf|eot|woff|woff2)$/,

loader: 'file-loader',

options: {

name: 'fonts/[name].[ext]',

}

},

{

test: /\.(gif|jpg|jpeg|png|svg)$/,

use: [

{

loader: 'url-loader',

options: {

limit: 1024,

name: 'fonts/[name].[hash:7].[ext]'

}

}

]

}

]

},

// plugins: [

//     // {

//     //     filename: 'index' + '.html',

//     //     template: 'index' + '.html'

//     // }

// ]

plugins: [

new webpack.DefinePlugin({

'process.env': {

NODE_ENV: isDev ? '"development"' : '"production"'

}

}),

// new webpack.optimize.CommonsChunkPlugin({ //v5 最少2个文件开始提取共用模块

//     async: 'async-common',

//     children: true, // 如果设置为 `true`,所有  公共chunk 的子模块都会被选择

//     minChunks: 2

// }),

// new webpack.optimize.CommonsChunkPlugin({ //v2 打包lodash

//     name: 'vendor',

//     minChunks: 1

// }),

new HTMLPlugin()

]

}

if (isDev) {

config.module.rules.push({

test: /\.styl/,

use: [

'style-loader',

'css-loader',

{

loader: 'postcss-loader'

// options:

//     sourceMap: options.sourceMap,

//     modules: true  //添加

// }

},

'stylus-loader'

]

})

config.devtool = '#cheap-module-eval-source-map'

config.devServer = {

port: 8000,

host: '0.0.0.0',

overlay: {

errors: true,

},

hot: true

}

config.plugins.push(

new webpack.HotModuleReplacementPlugin(),

new webpack.NoEmitOnErrorsPlugin()

)

} else {

config.entry = {

app: path.join(__dirname, 'src/main.js')

// vendor: ['vue']

}

config.devtool = '#source-map'

config.output.filename = 'pk-skin.[name].min.js'

}

module.exports = config

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值