Skip to content
Snippets Groups Projects
webpack.config.js 1.6 KiB
Newer Older
const config = {
  context: `${__dirname}/src`, // `__dirname` is root of project and `src` is source
scmoritz's avatar
scmoritz committed

scmoritz's avatar
scmoritz committed

  output: {
    path: `${__dirname}/dist`, // `dist` is the destination
    filename: 'bundle.js',
  },
scmoritz's avatar
scmoritz committed

  // To run development server
  devServer: {
    contentBase: __dirname,
    publicPath: '/dist/',
    compress: true,
    port: 9000,
    hot: true,
    index: 'index.html',
  },
scmoritz's avatar
scmoritz committed

  module: {
    rules: [
      {
        test: /\.js$/, // Check for all js files
        exclude: /node_modules/,
        use: [
          {
            loader: 'babel-loader',
            options: { presets: ['env'] },
          },
        ],
        test: /src\/views\/companies\/markdown\/[a-zA-Z\d-]{3,}\.[a-z]{2}\.md$/, // Check for all .md files in /companies/markdown
        use: [
          {
            loader: 'file-loader', // Writes the generated HTML to a file
            options: {
              name: '[name].html',
              outputPath: 'companies/',
              publicPath: 'dist/companies/',
            },
          },
          {
            loader: 'markdown-loader', // Converts Markdown to HTML
          },
        ],
      },
      {
        test: /\.less$/,
        use: [
          {
            loader: 'style-loader', // creates style nodes from JS strings
          },
          {
            loader: 'css-loader', // translates CSS into CommonJS
          },
          {
            loader: 'less-loader', // compiles Less to CSS
          },
        ],
      },
scmoritz's avatar
scmoritz committed

  devtool: 'eval-source-map', // Default development sourcemap
scmoritz's avatar
scmoritz committed
};