1、jquery is not defined:

解决:

webpack.prod.conf.js:

new webpack.DefinePlugin({
      'process.env': env,
      $ : 'jquery',
      jQuery : 'jquery'
    }),

改为:

new webpack.ProvidePlugin({
           $: "jquery",
           jQuery: "jquery"
    }),

2、静态资源路径找不到

解决:

config > index.js:

build: {
    env: require('./prod.env'),
    index: path.resolve(__dirname, '../dist/index.html'),
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    productionSourceMap: true,
    ...
}

改为:

build: {
    env: require('./prod.env'),
    index: path.resolve(__dirname, '../dist/index.html'),
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    assetsPublicPath: './',
    productionSourceMap: true,
    ...
}

把绝对路径改为相对路径


Logo

前往低代码交流专区

更多推荐