前提・実現したいこと
【webpackのエントリーポイントで複数のファイルを指定したい】
globを使って、ワイルドカード指定をしているのですが、実行するとエラーが返ってきてしまいます
また、webpack-glob-entry
とglob
どちらを使うほうがいいのでしょうか
webpack.common.js
const ExtractTextWebpackPlugin = require('extract-text-webpack-plugin'); const autoprefixer = require('autoprefixer'); module.exports = { output: { path: __dirname, filename: '[name]' }, module: { rules: [ { test: /.js$/, use: [{ loader: 'babel-loader', options: { presets: 'env' } }], exclude: /node_modules/, }, { test: /.scss$/, use: [ ExtractTextWebpackPlugin.loader, { loader: 'css-loader', options: { url: false, sourceMap: true, minimize: true } }, { loader: 'sass-loader', options: { sourceMap: true } }, { loader: 'postcss-loader', options: { sourceMap: true, plugins: [ autoprefixer({ browsers: 'last 2 versions', grid: true }) ] } } ] } ] }, plugins: [ new ExtractTextWebpackPlugin('[name]'), ] };
webpack.dev.js
const merge = require('webpack-merge') const common = require('./webpack.common.js') const path = require('path') const entry = require('webpack-glob-entry') module.exports = merge(common, { mode: 'development', entry: { './dest/assets/application.js': './src/js/index.js', './dest/assets/style.css': './src/sass/index.scss', './dest/': entry('./src/php/*.php') }, devtool: 'source-map', });
package.json(npm run dev
で実行しています)
{ "name": "new-webpack", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "start": "webpack-dev-server --hot --inline --config webpack.dev.js", "dev": "webpack --watch --inline --config webpack.dev.js", "build": "webpack --config webpack.prod.js" }, "author": "", "license": "ISC", "devDependencies": { "autoprefixer": "^9.3.1", "babel-core": "^6.26.3", "babel-loader": "^7.1.5", "babel-preset-env": "^1.7.0", "browser-sync": "^2.26.3", "browsersync-ssi": "^0.2.4", "css-loader": "^0.28.10", "extract-text-webpack-plugin": "^4.0.0-beta.0", "glob": "^7.1.3", "node-sass": "^4.10.0", "postcss-loader": "^3.0.0", "sass-loader": "^7.1.0", "webpack": "^4.26.0", "webpack-cli": "^3.1.2", "webpack-dev-server": "^3.1.10", "webpack-glob-entry": "^2.1.1", "webpack-merge": "^4.1.4" }, "dependencies": {} }
エラーメッセ-ジ
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. - configuration.entry should be one of these: function | object { <key>: non-empty string | [non-empty string] } | non-empty string | [non-empty string] -> The entry point(s) of the compilation. Details: * configuration.entry should be an instance of function -> A Function returning an entry object, an entry string, an entry array or a promise to these things. * configuration.entry['./dest/'] should be a string. -> The string is resolved to a module which is loaded upon startup. * configuration.entry['./dest/'] should be an array: [non-empty string] * configuration.entry should be a string. -> An entry point without name. The string is resolved to a module which is loaded upon startup. * configuration.entry should be an array: [non-empty string]
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/12/04 01:22
2018/12/04 01:46 編集