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

Patterns build twice when using webpack.app.js extend. #23

Closed
jeroenkampinga opened this issue May 8, 2018 · 3 comments
Closed

Patterns build twice when using webpack.app.js extend. #23

jeroenkampinga opened this issue May 8, 2018 · 3 comments
Assignees
Labels

Comments

@jeroenkampinga
Copy link
Contributor

jeroenkampinga commented May 8, 2018

When extending the Webpack build with the provided webpack.app.js the mustache files always get build. Even when changing for example only .scss files. Also the patterns are build twice which is killing for performance.

I assume the watcher in the webpack.config.babel.js does a bit more than It should, is this correct or is the issue within my setup down below.

My webpack.app.js file:

module.exports = env => {
  const {ifProd, ifDev} = getIfUtils(env);

  let stylesExtract = new ExtractTextPlugin({
    filename: 'css/main.css'
  });

  const app = {
    entry: [
      './_sass/style.scss',
      './_js/main.js'
    ],
    module: {
      rules: [
        {
          test: /\.js$/,
          enforce: 'pre',
          use: {
              loader: 'eslint-loader',
              options: {
                  configFile: '.eslintrc',
              },
          },
          exclude: [/node_modules/, path.join(plConfig.paths.source.root, 'js', 'libs')],
          include: [path.join(plConfig.paths.source.root, 'js')],
        },
        {
          test: /\.scss$/,
          exclude: path.resolve('node_modules'),
          use: ExtractTextPlugin.extract({
            fallback: 'style-loader',
            use: [
              {
                loader: 'css-loader',
                options: {
                  // If you are having trouble with urls not resolving add this setting.
                  // See https://github.com/webpack-contrib/css-loader#url
                  url: false,
                  minimize: true,
                  sourceMap: true,
                }
              },
              {
                loader: 'postcss-loader',
                options: {
                  plugins: () => [autoprefixer],
                  sourceMap: true
                },
              },
              {
                loader: 'sass-loader',
                options: {
                  includePaths: [path.join(plConfig.paths.source.root, 'scss')],
                  sourceMap: true
                }
              },
            ],
          }),
        },
        {
            test: /\.(eot|svg|ttf|woff|woff2)$/,
            use: {
              loader: 'file-loader',
              options: {
                name: '/assets/fonts/[name].[ext]',
              },
            },
            include: [path.join(plConfig.paths.source.root, 'assets', 'fonts')],
        }
      ]
    },
    resolve: {
      extensions: ['.js', '.css', '.scss']
    },
    output: {
      filename: 'js/[name].js',
      path: path.resolve(plConfig.paths.public.root)
    },
    plugins: [
      // Extract the generated css
      stylesExtract,

      new StyleLintPlugin({
        syntax: 'scss'
      })
    ],
  }
  return app;
 }
@mbulfair
Copy link
Member

mbulfair commented May 8, 2018

@jeroenkampinga Thank you for submitting this, I actually have noticed this when I did some recent extended work with sass. I'll investigate it, and report back here. If you figure out a solution before that, please document it, and submit a pull request. Much appreciated.

@mbulfair mbulfair self-assigned this May 8, 2018
@mbulfair mbulfair mentioned this issue May 8, 2018
@mbulfair mbulfair added the staged for next release code for the next release label Jun 12, 2018
@mbulfair
Copy link
Member

@jeroenkampinga This issue has been addressed with the upcoming release. I'm also providing a working sample of scss loader/plugins that I use and have tested. The events have also been adjusted to prevent duplication.

@jeroenkampinga
Copy link
Contributor Author

@mbulfair Sounds good, looking forward to the new release!

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

No branches or pull requests

2 participants