明仕msyz555注册webpack入门配置题目?

初学webpack,参照材料配置不断报错,费事给辅导一下!!!
错误提示:ERROR in multi main
Module not found: Error: Cannot resolve file or directory ./public/pages/index.js in D:websitewebpack\
我配置的代码config文件如下:

// config/webpack.config.js
const webpack = requirewebpack;

// 配置目次
// 由于我们的webpack.config.js文件不在项目根目次下,以是需求一个途径的配置
const path = requirepath;
const CURRENT_PATH = path.resolve__dirname; // 获取到以后目次
const ROOT_PATH = path.join__dirname, ../; // 项目根目次
const MODULES_PATH = path.joinROOT_PATH, ./node_modules; // node包目次
const BUILD_PATH = path.joinROOT_PATH, ./public/assets; // 最后输入安排群众资源的目次
const ExtractTextPlugin = require"extract-text-webpack-plugin";
module.exports = {
    context: path.join__dirname, ../, // 设置webpack配置中指向的默许目次为项目根目次
    entry: {
        index: ./public/pages/index.js,
        public: ./public/pages/public.js
    },
    output: {
        path: BUILD_PATH, // 设置输入目次
        filename: [name].bundle.js, // 输入文件名
    },
    resolve: {
        extensions: [, .js, .jsx, .coffee] // 配置简写,配置当时,誊录该文件途径的时分可以省略文件后缀
    },
    module: {
        loaders: [
            // style & css & less loader
            { test: /\.css$/, loader: ExtractTextPlugin.extractstyle-loader, css-loader},
            { test: /\.less$/, loader: ExtractTextPlugin.extractstyle, css!less },
            // babel loader
            {
                test: /\.jsx?$/,
                exclude: /node_modules|bower_components/,
                loader: [babel-loader],
                query: {
                  presets: [es2015]
                  // 假如安装了React的话
                  // presets: [react, es2015]
                }
            },
            // image & font
            { test: /\.woff|woff2|eot|ttf|otf$/i, loader: url-loader?limit=8192&name=[name].[ext]},
            { test: /\.jpe?g|png|gif|svg$/i, loader: url-loader?limit=8192&name=[name].[ext]},
            // expose-loader将需求的变量从依赖包中表表现来
            { test: require.resolve"jquery", loader: "expose?$! expose?jQuery" },
            {
                test: /\.jsx?$/,
                exclude: /node_modules|bower_components/,
                loader: [babel-loader],
                query: {
                    presets: [react, es2015]
                }
            }
        ]
    },
    plugins: [
        // 别离css
        new ExtractTextPlugin[name].bundle.css, {
            allChunks: true
        },
        // public sources
        new webpack.optimize.CommonsChunkPlugin{
            // 与 entry 中的 jquery 对应
            name: jquery,
            // 输入的群众资源称号
            filename: common.bundle.js,
            // 对统统entry实行这个规矩
            minChunks: Infinity
        },
        new webpack.optimize.UglifyJsPlugin{
            mangle: {
              except: [$super, $, exports, require]
              //以上变量‘$super’, ‘$’, ‘exports’ or ‘require’,不会被稠浊
            },
            compress: {
              warnings: false
            }
        },
        new webpack.DefinePlugin{
            "process.env": { 
                NODE_ENV: JSON.stringify"production" 
            }
        }
    ]
}

报错信息提示你

Module not found: Error: Cannot resolve file or directory ./public/pages/index.js in D:websitewebpack\

以是反省一下,在websitewebpack能否存在public/pages/index.js.

按下面这个目次层级查找

- websitewebpack
  - public
    - pages
       index.js

(看完/读完)这篇文章有何感想! 明仕msyz555注册的分享…

发表评论

姓名 *
电子邮件 *
站点