0

I have the following folder structure:

|- webpack.config.js
|- src/
  |- main.js
  |- some.other.js.files
|- styles/
  |- app.scss
  |- animation.scss
  |- transition.scss
|- public/
  |- js/
    |- app.js

I have Webpack configured such that it takes all the css and js files and compiles them as app.js under public/js. Here is the config:

module.exports = {
  entry: './src/main.js',
  output: {
    path: path.to.public.js,
    filename: 'app.js'
  },
  module: {
    rules: [
      { test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ },
      { test: /\.scss$/, loaders: ["style-loader", "css-loader", "sass-loader"]},
  }
}

Now I want to create another scss file, called static.scss, and instead of getting it added to app.js like the others, I want it to be compiled into a stand-alone css file under public/css. This is so that I can link to it from some html files I have elsewhere in the repository.

How do I do this?

1 Answer 1

1

You can extract specific targeted css using Extract Text WebPack Plugin: https://webpack.js.org/plugins/extract-text-webpack-plugin/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.