Closed Mitriyweb closed 6 years ago
It does work well without minification and with vue.esm.js. But it doesnot work with vue/dist/vue.min.js and minification webpack config:
vue.esm.js
vue/dist/vue.min.js
const path = require('path'); const webpack = require('webpack'); const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); const { VueLoaderPlugin } = require('vue-loader'); const __dirSource = path.resolve(__dirname, './src'); const __dirJs = path.resolve(__dirSource, './js'); const __dirAssets = path.resolve(__dirname, './assets'); const LIFE = process.argv.indexOf('-p') !== -1; let config = { devtool: LIFE ? 'none' : 'source-map', context: __dirSource, entry: { app: [ path.resolve(__dirJs, './index.js') ], }, output: { path: path.resolve(__dirAssets, './js'), filename: LIFE ? 'bundle.min.js' : 'bundle.js', }, externals: {}, module: { rules: [], loaders: [] }, plugins: [], resolve: { alias: { 'vue$': LIFE ? 'vue/dist/vue.min.js' : 'vue/dist/vue.esm.js' } } }; // eslint config.plugins.push( new webpack.LoaderOptionsPlugin({ options: { eslint: { failOnWarning: false, failOnError: false, fix: true, quiet: false, }, }, }) ); config.module.rules.push({ test: /\.js$/, enforce: 'pre', exclude: /(node_modules|assets|tests|\.spec\.js)/, use: [ { loader: 'eslint-loader', options: { failOnWarning: false, failOnError: false } } ] }); // babel loader config.module.rules.push({ test: /\.js$/, exclude: /node_modules/, use: { loader: 'babel-loader', options: { cacheDirectory: true, presets: [ ['env', { targets: { browsers: [ "last 2 versions", "safari >= 8", "ie >= 10" ] } }] ] } } }); // pug loader config.module.rules.push({ test: /\.pug/, loaders: ['html-loader', 'pug-html-loader'] }); // vue loader config.module.rules.push({ test: /\.vue$/, use: ['vue-loader', 'vue-template-loader'] }); // vue config.plugins.push(new VueLoaderPlugin()); // no emit plugin config.plugins.push(new webpack.NoEmitOnErrorsPlugin()); // uglify plugin if (LIFE) { config.plugins.push(new webpack.optimize.UglifyJsPlugin({sourceMap: true})); } module.exports = config;
Without --optimize-minimize all work
--optimize-minimize
It does work well without minification and with
vue.esm.js
. But it doesnot work withvue/dist/vue.min.js
and minification webpack config: