Closed guiter closed 7 years ago
// ------- webpack.base.config.js ------ start
"use strict" var ExtractTextPlugin = require("extract-text-webpack-plugin"); var path = require("path"); const vuxLoader = require('vux-loader'); var entry = [path.resolve(dirname, "../src/views/main")], cdnPrefix = "", buildPath = path.resolve(dirname, "../dist/gzh/"), publishPath = "/gzh/";
const webpackConfig = { entry: { index:entry, vendors: ["vue","vue-router","vue-resource","vue-touch","./src/libs/vue-zoom","./src/libs/vue-scroll","./src/libs/vue-model"] }, output: { path: path.resolve(dirname, buildPath), filename: "[name][hash].js", publicPath: publishPath, chunkFilename: "[id].[chunkhash].js" }, externals: { "BMap": "BMap", "wx":"wx" }, module: { rules:[{ test: /.vue$/, loader: "vue-loader", }, { test: /.scss$/, loader: ExtractTextPlugin.extract( {fallback:"style-loader", use:["css-loader?sourceMap!sass-loader!cssnext-loader"]} ) }, { test: /.css$/, loader: ExtractTextPlugin.extract( {fallback:"style-loader", use:["css-loader?sourceMap!sass-loader!cssnext-loader"]}) }, { test: /.less$/, loader: ExtractTextPlugin.extract( {fallback:"style-loader", use:["css-loader?sourceMap!less-loader!cssnext-loader"]}) },{ test: /.js$/, loader: "babel-loader", include:[path.resolve(dirname, "../src")] }, { test: /.(jpg|png|gif)$/, loader: "file-loader?images/[hash].[ext]" }, { test: /.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/, loader: "url-loader?limit=10000&minetype=application/font-woff" }, { test: /.(ttf|eot|svg)(\?v=[0-9].[0-9].[0-9])?$/, loader: "file-loader?" }, { test: /.json$/, loader: "json-loader" }, { test: /.(html|tpl)$/, loader: "html-loader" }] }, resolve: { extensions: [".js",".vue"], modules:[ path.resolve(dirname, "../src"), path.resolve(dirname, "../node_modules") ], alias: { "src": path.resolve(dirname, "../src"), "assets": path.resolve(dirname, "../src/assets"), "components": path.resolve(dirname, "../src/components"), "baseView": path.resolve(dirname, "../src/views"),
} }
};
module.exports = vuxLoader.merge(webpackConfig, { plugins: ['vux-ui'] })
// ----------- webpack.base.config.js --------- end
// ----------- package.json --------- start
{ "name": "webpack", "version": "1.0.0", "main": "index.js", "scripts": { "dev": "cross-env node ./build/dev-server.js", "test": "webpack --display-modules --display-chunks --config build/webpack.test.conf.js" }, "keywords": [], "author": "", "license": "ISC", "devDependencies": { "autoprefixer-loader": "^3.2.0", "babel": "^6.5.2", "babel-core": "^6.22.1", "babel-eslint": "^7.1.1", "babel-loader": "^6.3.2", "babel-plugin-istanbul": "^3.1.2", "babel-plugin-transform-runtime": "^6.22.0", "babel-preset-es2015": "^6.22.0", "babel-preset-stage-2": "^6.22.0", "babel-register": "^6.22.0", "babel-runtime": "^6.20.0", "clean-webpack-plugin": "^0.1.14", "cross-env": "^2.0.0", "css-loader": "^0.28.2", "cssnext-loader": "^1.0.1", "del": "^2.2.1", "express": "^4.14.0", "extract-text-webpack-plugin": "^2.0.0", "fastclick": "^1.0.6", "file-loader": "^0.9.0", "function-bind": "^1.1.0", "html-loader": "^0.4.3", "html-webpack-plugin": "^2.24.1", "http-proxy-middleware": "^0.17.2", "inject-loader": "^2.0.1", "iscroll": "^5.2.0", "json-loader": "^0.5.4", "json-server": "^0.8.17", "lodash": "^4.14.1", "less":"^2.7.2", "less-loader":"^4.0.5", "markdown": "^0.5.0", "mock": "^0.1.1", "mockjs": "^1.0.1-beta2", "node-sass": "^3.8.0", "object-assign": "^4.1.0", "precss": "^1.4.0", "sass-loader": "^4.0.0", "store": "^1.3.20", "style-loader": "^0.13.1", "url-loader": "^0.5.7", "video.js": "^5.11.6", "vue": "^2.1.6", "vue-hot-reload-api": "1.3.3", "vue-html-loader": "^1.2.3", "vue-loader": "^13.0.0", "vue-template-compiler": "^2.3.3", "vue-resource": "^0.9.3", "vue-router": "^2.5.1", "vue-style-loader": "^3.0.0", "vue-touch": "^2.0.0-beta.4", "vue-swipe": "^2.0.2", "vux":"^2.2.0", "vux-loader":"^1.0.56", "webpack": "^3.1.0", "webpack-bundle-analyzer": "^2.2.1", "webpack-dev-middleware": "^1.8.4", "webpack-dev-server": "^1.15.1", "webpack-hot-middleware": "^2.13.2", "webpack-merge": "^2.6.1" }, "dependencies": { "vue": "^2.3.3", "vue-router": "^2.0.0" }, "description": "" }
// ----------- package.json --------- end
// -------- 编译打包完成后 访问 vue 报错误
Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
//------ 似乎es6 没转码成功,但去掉配置后转码,运行都正常,请求指导
这是 node 版本太低了吧。
// ------- webpack.base.config.js ------ start
"use strict" var ExtractTextPlugin = require("extract-text-webpack-plugin"); var path = require("path"); const vuxLoader = require('vux-loader'); var entry = [path.resolve(dirname, "../src/views/main")], cdnPrefix = "", buildPath = path.resolve(dirname, "../dist/gzh/"), publishPath = "/gzh/";
const webpackConfig = { entry: { index:entry, vendors: ["vue","vue-router","vue-resource","vue-touch","./src/libs/vue-zoom","./src/libs/vue-scroll","./src/libs/vue-model"] }, output: { path: path.resolve(dirname, buildPath), filename: "[name][hash].js", publicPath: publishPath, chunkFilename: "[id].[chunkhash].js" }, externals: { "BMap": "BMap", "wx":"wx" }, module: { rules:[{ test: /.vue$/, loader: "vue-loader", }, { test: /.scss$/, loader: ExtractTextPlugin.extract( {fallback:"style-loader", use:["css-loader?sourceMap!sass-loader!cssnext-loader"]} ) }, { test: /.css$/, loader: ExtractTextPlugin.extract( {fallback:"style-loader", use:["css-loader?sourceMap!sass-loader!cssnext-loader"]}) }, { test: /.less$/, loader: ExtractTextPlugin.extract( {fallback:"style-loader", use:["css-loader?sourceMap!less-loader!cssnext-loader"]}) },{ test: /.js$/, loader: "babel-loader", include:[path.resolve(dirname, "../src")] }, { test: /.(jpg|png|gif)$/, loader: "file-loader?images/[hash].[ext]" }, { test: /.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/, loader: "url-loader?limit=10000&minetype=application/font-woff" }, { test: /.(ttf|eot|svg)(\?v=[0-9].[0-9].[0-9])?$/, loader: "file-loader?" }, { test: /.json$/, loader: "json-loader" }, { test: /.(html|tpl)$/, loader: "html-loader" }] }, resolve: { extensions: [".js",".vue"], modules:[ path.resolve(dirname, "../src"), path.resolve(dirname, "../node_modules") ], alias: { "src": path.resolve(dirname, "../src"), "assets": path.resolve(dirname, "../src/assets"), "components": path.resolve(dirname, "../src/components"), "baseView": path.resolve(dirname, "../src/views"),
};
module.exports = vuxLoader.merge(webpackConfig, { plugins: ['vux-ui'] })
// ----------- webpack.base.config.js --------- end
// ----------- package.json --------- start
{ "name": "webpack", "version": "1.0.0", "main": "index.js", "scripts": { "dev": "cross-env node ./build/dev-server.js", "test": "webpack --display-modules --display-chunks --config build/webpack.test.conf.js" }, "keywords": [], "author": "", "license": "ISC", "devDependencies": { "autoprefixer-loader": "^3.2.0", "babel": "^6.5.2", "babel-core": "^6.22.1", "babel-eslint": "^7.1.1", "babel-loader": "^6.3.2", "babel-plugin-istanbul": "^3.1.2", "babel-plugin-transform-runtime": "^6.22.0", "babel-preset-es2015": "^6.22.0", "babel-preset-stage-2": "^6.22.0", "babel-register": "^6.22.0", "babel-runtime": "^6.20.0", "clean-webpack-plugin": "^0.1.14", "cross-env": "^2.0.0", "css-loader": "^0.28.2", "cssnext-loader": "^1.0.1", "del": "^2.2.1", "express": "^4.14.0", "extract-text-webpack-plugin": "^2.0.0", "fastclick": "^1.0.6", "file-loader": "^0.9.0", "function-bind": "^1.1.0", "html-loader": "^0.4.3", "html-webpack-plugin": "^2.24.1", "http-proxy-middleware": "^0.17.2", "inject-loader": "^2.0.1", "iscroll": "^5.2.0", "json-loader": "^0.5.4", "json-server": "^0.8.17", "lodash": "^4.14.1", "less":"^2.7.2", "less-loader":"^4.0.5", "markdown": "^0.5.0", "mock": "^0.1.1", "mockjs": "^1.0.1-beta2", "node-sass": "^3.8.0", "object-assign": "^4.1.0", "precss": "^1.4.0", "sass-loader": "^4.0.0", "store": "^1.3.20", "style-loader": "^0.13.1", "url-loader": "^0.5.7", "video.js": "^5.11.6", "vue": "^2.1.6", "vue-hot-reload-api": "1.3.3", "vue-html-loader": "^1.2.3", "vue-loader": "^13.0.0", "vue-template-compiler": "^2.3.3", "vue-resource": "^0.9.3", "vue-router": "^2.5.1", "vue-style-loader": "^3.0.0", "vue-touch": "^2.0.0-beta.4", "vue-swipe": "^2.0.2", "vux":"^2.2.0", "vux-loader":"^1.0.56", "webpack": "^3.1.0", "webpack-bundle-analyzer": "^2.2.1", "webpack-dev-middleware": "^1.8.4", "webpack-dev-server": "^1.15.1", "webpack-hot-middleware": "^2.13.2", "webpack-merge": "^2.6.1" }, "dependencies": { "vue": "^2.3.3", "vue-router": "^2.0.0" }, "description": "" }
// ----------- package.json --------- end
// -------- 编译打包完成后 访问 vue 报错误
Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
//------ 似乎es6 没转码成功,但去掉配置后转码,运行都正常,请求指导