-
Notifications
You must be signed in to change notification settings - Fork 0
Description
-
I'm submitting a ...
[x] bug report
[ ] feature request
[ ] question about the decisions made in the repository
[ ] question about how to use this project -
Summary
webpack config setting resolve.alias seem can not work with this plugin. -
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)
First of all, sorry that I can not provide a test sample case. But I'll try draft out the problem I faced and how I workaround it. Here is snippet of my webpack config:
...
, resolve: {
modules: [__baseModulePath]
, extensions: ['.js', '.jsx']
, alias: {
...
, 'jquery-spellchecker': path.resolve(__dirname, './vendor/jquery.spellchecker.js')
...
}
}
...
, resolveLoader: {
modules: [ __baseModulePath ]
}
, module: {
...
, rules: [
...
, {
test: /\.s[ac]ss$/
, issuer: {
exclude: /styles\/_variables\.js$/
}
, use: ExtractTextPlugin.extract({
fallback: __baseModulePath + "style-loader"
, use: __baseModulePath+"css-loader!"+__baseModulePath + "sass-loader"
})
}
, {
test: /\.css$/
, use: ExtractTextPlugin.extract({
fallback: __baseModulePath + "style-loader"
, use: __baseModulePath + "css-loader"
})
}
, {
test: /sass\/_variables\.scss$/
, issuer: {
test: /styles\/_variables\.js$/
}
// NOTE.1: options.cwd is needed to avoid this loader some how
// reset resolve.alias.
, use: { loader: 'sass-variable-parser', options: { cwd: "" } }
}
...
]
}
where __dirname is <path-to-my-app>/web and __baseModulePath is <module-path>/npm/lib/node_modules/ and note the NOTE.1 which is my hack to solve this problem. Some where in my application I have a file call <path-to-my-app>/web/app/components/v5/Spellcheck.js which has one of this import (using alias):
...
import 'jquery-spellchecker';
...
Without options.cwd = '', error below will appear:
ERROR in ./app/components/v5/Spellchecker.js
Module not found: Error: Can't resolve '../../../sass/vendor/jquery.spellchecker.js' in '<path-to-my-app>/web/app/components/v5'
resolve '../../../sass/vendor/jquery.spellchecker.js' in '<path-to-my-app>/web/app/components/v5'
using description file: <path-to-my-app>/web/package.json (relative path: ./app/components/v5)
Field 'browser' doesn't contain a valid alias configuration
after using description file: <path-to-my-app>/web/package.json (relative path: ./app/components/v5)
using description file: <path-to-my-app>/web/package.json (relative path: ./sass/vendor/jquery.spellchecker.js)
no extension
Field 'browser' doesn't contain a valid alias configuration
<path-to-my-app>/web/sass/vendor/jquery.spellchecker.js doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
<path-to-my-app>/web/sass/vendor/jquery.spellchecker.js.js doesn't exist
.jsx
Field 'browser' doesn't contain a valid alias configuration
<path-to-my-app>/web/sass/vendor/jquery.spellchecker.js.jsx doesn't exist
as directory
<path-to-my-app>/web/sass/vendor/jquery.spellchecker.js doesn't exist
[<path-to-my-app>/web/sass/vendor/jquery.spellchecker.js]
[<path-to-my-app>/web/sass/vendor/jquery.spellchecker.js.js]
[<path-to-my-app>/web/sass/vendor/jquery.spellchecker.js.jsx]
[<path-to-my-app>/web/sass/vendor/jquery.spellchecker.js]
@ ./app/components/v5/Spellchecker.js 10:0-53
@ ./app/components/v5/ReplyToolbar.js
@ ./app/views/v5/errandCtnrs.js
@ ./app/containers/app.js
@ ./app/workflowv5App.js
May be there is some bug that cause this?