Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Webpack's aliases / modulesDirectories #1

Closed
rpunkfu opened this issue Nov 18, 2016 · 10 comments
Closed

Support for Webpack's aliases / modulesDirectories #1

rpunkfu opened this issue Nov 18, 2016 · 10 comments
Assignees

Comments

@rpunkfu
Copy link

rpunkfu commented Nov 18, 2016

Awesome plugin, would be nice to support aliases / modulesDirectories :)

@rpunkfu
Copy link
Author

rpunkfu commented Nov 18, 2016

I managed to implement this, still need some refactor, but will try to open PR tomorrow :)

@princed
Copy link
Owner

princed commented Nov 18, 2016

Great idea! I'd add some resolve function call in walkFile.

@kumarharsh
Copy link
Contributor

+1 this can be great. Also, nice work @princed. Although, how do I use this? I'm using webpack's css-loader.

@princed
Copy link
Owner

princed commented Nov 24, 2016

@kumarharsh Thanks! See usage examples in README, you have to use postcss-loader.

@kumarharsh
Copy link
Contributor

kumarharsh commented Nov 24, 2016

@princed here's my config:

/* webpack.config.js */
{
  test:  /\.css$/,
  exclude: path.resolve('./node_modules'),
  loaders: [
    'style-loader',
    'css-loader?modules&camelCase&sourceMap&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]',
    'postcss-loader',
  ],
},
/* postcss.config.js */
module.exports = {
  plugins: [
    require('postcss-import'),
    require('postcss-modules-values-replace'),
    require('postcss-custom-properties')(),
    require('postcss-color-function'),
    require('autoprefixer'),
  ],
};

Also, I'm guessing the part in the README about:

{
  postcss: webpack => [
    require('postcss-modules-values-replace')({fs: webpack._compiler.inputFileSystem}),
    require('postcss-calc')
  ]
}

is optional, and has to be written in the webpack configuration? Because my postcss config is a separate json file. I made a mistake, it's a JS file.


But when I use @value in my code, the values don't get replaced. If I disable your plugin the @value do get replaced.

@kumarharsh
Copy link
Contributor

@rpunkfu can you share some version of the working code? I'd like to use it too in my project, but am not really fluent in webpack/postcss internals. Maybe I can help a little in the refactor...

@rpunkfu
Copy link
Author

rpunkfu commented Nov 26, 2016

I managed to implement this feature but, I didnt manage to get hot reload working, when changing file imported via @value rule, I dont really see way to do it and lack of this feature makes this plugin useless for me :(

@rpunkfu
Copy link
Author

rpunkfu commented Nov 26, 2016

I deleted code, but maybe I will try to work on it again and share code for others, who doesnt care about feature mentioned above :)

@princed princed closed this as completed in 07eb5ef Feb 9, 2017
@princed
Copy link
Owner

princed commented Feb 9, 2017

Shipped in 1.2.0

@princed princed assigned princed and unassigned rpunkfu Feb 10, 2017
@kumarharsh
Copy link
Contributor

@princed I'm still getting the same error Module build failed: Error: Can't resolve 'css/shared/colors.css' in ..... I have resolve.modulesDirectories set to ['src', 'node_modules'] in webpack config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants