storybookjs/vue-cli-plugin-storybook

failed to load less file in component

Closed this issue · 1 comments

When there is a less file in my component, it will report error:
ERROR in ./packages/vue-my-radio/src/vue-my-radio.less 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

For somebody use vue cli3 with storybook and only have vue.config.js in your project, you can create a webpack.config.js in .storybook folder with following content:
module.exports = async ({ config }) => {
config.resolve.extensions.push('.vue', '.css', '.less', '.scss', '.sass', '.html')
config.module.rules.push({ test: /.less$/, loaders: [ 'style-loader', 'css-loader', 'less-loader' ] });
config.module.rules.push({ test: /.styl$/, loader: 'style-loader!css-loader!stylus-loader' });

return config;
};