我正在尝试在我的应用程序中设置 Grommet-standalone。
我刚刚了解到 webpack 配置中的自定义属性不再受支持。所以sassLoader
不起作用。我似乎无法替代webpack.LoaderOptionsPlugin
, 来工作。
这个类似问题的解决方案对我不起作用。
看看我的webpack.config.js
:
/* eslint no-var: 0 */
var path = require('path');
var webpack = require('webpack');
var WriteFilePlugin = require('write-file-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var APP_DIR = path.resolve(__dirname, 'app');
module.exports = {
entry: [
'webpack-dev-server/client?http://localhost:8081',
'webpack/hot/only-dev-server',
path.join(APP_DIR, 'index.jsx')
],
output: {
path: path.join(__dirname, 'build'),
filename: 'bundle.js'
},
devServer: {
contentBase: './build',
hot: true,
inline: true,
historyApiFallback: true
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(APP_DIR, 'index.tmp.html')
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.LoaderOptionsPlugin({
debug: true,
options: {
sassLoader: {
includePaths: [
'./node_modules',
// this is required only for NPM < 3.
// Dependencies are flat in NPM 3+ so pointing to
// the internal grommet/node_modules folder is not needed
'./node_modules/grommet/node_modules'
]
}
}
}),
new WriteFilePlugin()
],
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules|bower_components/,
loader: 'babel-loader'
},
{
test: /\.scss$/,
loader: 'style-loader!css-loader!sass-loader?outputStyle=compressed'
}
]
}
};
这是我得到的错误:
ERROR in ./~/css-loader!./~/sass-loader/lib/loader.js?outputStyle=compressed!./~/grommet/scss/vanilla/index.scss
Module build failed:
undefined
^
File to import not found or unreadable: inuit-defaults/settings.defaults.
Parent style sheet: C:/Users/TeneceUBA2/workspaces/sts/eagleswings/src/main/resources/public/node_modules/grommet/scss/grommet-core/_settings.scss
in C:\Users\TeneceUBA2\workspaces\sts\eagleswings\src\main\resources\public\node_modules\grommet\scss\grommet-core\_settings.scss (line 4, column 1)
@ ./~/grommet/scss/vanilla/index.scss 4:14-130 13:2-17:4 14:20-136
@ ./app/index.jsx
@ multi (webpack)-dev-server/client?http://localhost:8081 webpack/hot/dev-server webpack-dev-server/client?http://localhost:8081 webpack/hot/only-dev-server ./app/index.jsx
为了完整起见,这是我的package.json
{
"name": "eagles",
"version": "1.0.0",
"description": "desc",
"main": "index.js",
"scripts": {
"dev": "webpack --config webpack.config.js",
"serve": "webpack-dev-server",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Tobe",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.22.1",
"babel-loader": "^6.2.10",
"babel-plugin-react-transform": "^2.0.2",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.22.0",
"css-loader": "^0.26.1",
"eslint": "^3.15.0",
"eslint-config-airbnb": "^14.1.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^4.0.0",
"eslint-plugin-react": "^6.9.0",
"html-webpack-plugin": "^2.28.0",
"node-sass": "^4.5.0",
"react-transform-hmr": "^1.0.4",
"sass-loader": "^5.0.1",
"style-loader": "^0.13.1",
"webpack": "^2.2.1",
"webpack-dev-server": "^2.3.0",
"write-file-webpack-plugin": "^3.4.2"
},
"dependencies": {
"grommet": "^1.2.1",
"inuit-defaults": "^0.2.3",
"react": "^15.4.2",
"react-dom": "^15.4.2"
}
}
有没有人让 Grommet 与 webpack2 一起工作?谷歌在这种情况下没有太多帮助。