package.json中代码
{
“name”: “3-5”,
“version”: “1.0.0”,
“description”: “”,
“main”: “index.js”,
“scripts”: {
“test”: “echo “Error: no test specified” && exit 1”
},
“keywords”: [],
“author”: “”,
“license”: “ISC”,
“devDependencies”: {
“babel-core”: “^6.26.3”,
“babel-loader”: “^7.1.5”,
“babel-plugin-lodash”: “^3.3.4”,
“babel-preset-env”: “^1.7.0”,
“css-loader”: “^2.0.0”,
“extract-text-webpack-plugin”: “^3.0.2”,
“file-loader”: “^2.0.0”,
“less”: “^3.9.0”,
“less-loader”: “^4.1.0”,
“node-sass”: “^4.11.0”,
“postcss-loader”: “^3.0.0”,
“sass-loader”: “^7.1.0”,
“style-loader”: “^0.23.1”,
“webpack”: “^3.12.0”,
“webpack-cli”: “^2.1.5”
},
“dependencies”: {
“lodash”: “^4.17.11”,
“lodash-es”: “^4.17.11”
}
}
webpack.config.js中代码
const path=require(‘path’)
const ExtractTextWebpackPlugin=require(‘extract-text-webpack-plugin’);
const webpack=require(‘webpack’);
module.exports={
entry:{
app:’./src/app.js’
},
output: {
path:path.resolve(__dirname,‘dist’),
publicPath: ‘./dist/’,
filename: ‘[name].bundle.js’,
chunkFilename: ‘[name].chunk.js’
},
module: {
rules: [
{
test:/.lessKaTeX parse error: Expected 'EOF', got '}' at position 607: …})
}̲,
{…/,
use:[{
loader:‘babel-loader’,
options:{
presets:[‘env’],
plugins:[‘lodash’]
}
}]
}
]
},
plugins: [
new ExtractTextWebpackPlugin({
filename: ‘[name].min.css’,
allChunks:false
}),
new webpack.optimize.UglifyJsPlugin()
]
}
app.js中代码
import base from './css/base.less’
import common from ‘./css/common.less’
import {a} from './common/util’
import {chunk} from 'lodash-es’
console.log(chunk([1,2,3,4,5],2))
运行webpack 出现报错
ERROR in ./node_modules/css-loader/dist/runtime/api.js
Module build failed: Error: Couldn’t find preset “@babel/preset-env” relative to directory “C:\Users\Administrator\Desktop\
3-12\node_modules\css-loader”
老师,这是怎么回事啊