'modify output path in webpack/ neutrino CssSyntaxError Unknown Word

I am using neutrino to set up how webpack is bundling specific files. In my case I am using webpack to bundle Material Design. I have used file-loader in a webpack.conifg.js before to specify the filename of the file created. In webpack.config.js, it looks like this.


module.exports = [{
  mode: 'production',
  entry: ['./material-design-custom.scss','./node_modules/material-components-web/dist/material-components-web.min.js'],
  output: {
    filename: 'bundle.js',
  },
  module: {
    rules: [
      {
        test: /\.scss$/,
        use: [
          {
            loader: 'file-loader',
            options: {
              name: 'bundle.css',
            },
          },
          { loader: 'extract-loader' },
          { loader: 'css-loader' },
          {
            loader: 'sass-loader',
            options: {
              webpackImporter: false,
              implementation: require('sass'),
              sassOptions: {
                includePaths: ['./node_modules']
              }
            },
          }
        ]
      },
    ]
  },
}];

In a .neutrinorc.js config file I have tried the following:


const styles = require('@neutrinojs/style-loader');
const copy = require('@neutrinojs/copy');
const path = require('path')


module.exports = {
    options: {
        output: 'test'
    },
  use: [
    styles({
      test: /\.(css|sass|scss)$/,
      modulesTest: /\.module\.(css|sass|scss)$/,
      loaders: [
          {
            loader: 'file-loader',
            options: {
              name: 'bundle.css',
            },
          },
        {
          loader: 'sass-loader',
          useId: 'sass',
          sassOptions: {
            webpackImporter: false,
            implementation: require.resolve("sass"),
            includePaths: ['./node_modules'],
          },
        },
      ],
    }),
    copy({
        patterns: [
          // Copy the custom.css file, replacing the values based on the theme.json file.
          {
            from: 'node_modules/material-components-web/dist/material-components-web.min.js',
            to: path.resolve(__dirname + '/dist', 'bundle.js'),
            force: true
          },
        ],
      })
  ],
};

On build, I am getting the following error:

Module build failed (from /Users/benjaminfi/dev/src/a_directory/node_modules/css-loader/dist/cjs.js):
CssSyntaxError

(1:1) Unknown word

> 1 | module.exports = __webpack_public_path__ + "bundle.css";

In general, my question is how to configure the output directory name and filename using neutrino to create css and js files. Neutrino online documentation is limited, so every advice is highly appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source