Last active
August 29, 2015 14:13
-
-
Save mars/41a8af52602f3f07212a to your computer and use it in GitHub Desktop.
example Webpack configs: React runtime & Karma tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var webpackModule = require('./webpack.module.js'); | |
| var webpackResolve = require('./webpack.resolve.js'); | |
| var Webpack = require('webpack'); | |
| var RewirePlugin = require("rewire-webpack"); | |
| module.exports = function(config) { | |
| config.set({ | |
| // frameworks to use | |
| // available frameworks: https://npmjs.org/browse/keyword/karma-adapter | |
| frameworks: ['jasmine-ajax', 'jasmine'], | |
| // Continuous Integration mode | |
| // if true, Karma captures browsers, runs the tests and exits | |
| singleRun: true, | |
| reporters: ['dots', 'junit'], | |
| junitReporter: { | |
| outputFile: 'test-results.xml' | |
| }, | |
| // level of logging | |
| // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | |
| logLevel: config.LOG_INFO, | |
| // start these browsers | |
| // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | |
| browsers: ['PhantomJS'], | |
| files: [ | |
| 'spec/**/*spec.{js,jsx}', | |
| // each file acts as entry point for the webpack configuration | |
| ], | |
| preprocessors: { | |
| 'spec/**/*spec.{js,jsx}': ['webpack'] | |
| }, | |
| webpack: { | |
| // karma watches the test entry points | |
| // (you don't need to specify the entry option) | |
| // webpack watches dependencies | |
| // webpack configuration | |
| target: "web", | |
| debug: true, | |
| plugins: [ | |
| new RewirePlugin(), | |
| new Webpack.IgnorePlugin(/^jquery/) | |
| ], | |
| // configs shared between environments | |
| module: webpackModule, | |
| resolve: webpackResolve | |
| }, | |
| webpackServer: { | |
| // webpack-dev-server configuration | |
| // webpack-dev-middleware configuration | |
| // i. e. | |
| noInfo: true | |
| }, | |
| // the port used by the webpack-dev-server | |
| // defaults to "config.port" + 1 | |
| webpackPort: 1234 | |
| }); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var webpackModule = require('./webpack.module.js'); | |
| var webpackResolve = require('./webpack.resolve.js'); | |
| var Webpack = require('webpack'); | |
| var RewirePlugin = require("rewire-webpack"); | |
| module.exports = function(config) { | |
| config.set({ | |
| // frameworks to use | |
| // available frameworks: https://npmjs.org/browse/keyword/karma-adapter | |
| frameworks: ['jasmine-ajax', 'jasmine'], | |
| // test results reporter to use | |
| // possible values: 'dots', 'progress' | |
| // available reporters: https://npmjs.org/browse/keyword/karma-reporter | |
| reporters: ['progress', 'osx'], | |
| // enable / disable colors in the output (reporters and logs) | |
| colors: true, | |
| // level of logging | |
| // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | |
| logLevel: config.LOG_INFO, | |
| // enable / disable watching file and executing tests whenever any file changes | |
| autoWatch: true, | |
| // start these browsers | |
| // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | |
| browsers: ['PhantomJS'], | |
| // Continuous Integration mode | |
| // if true, Karma captures browsers, runs the tests and exits | |
| singleRun: false, | |
| files: [ | |
| 'spec/**/*spec.{js,jsx}', | |
| // each file acts as entry point for the webpack configuration | |
| ], | |
| preprocessors: { | |
| 'spec/**/*spec.{js,jsx}': ['webpack'] | |
| }, | |
| webpack: { | |
| // karma watches the test entry points | |
| // (you don't need to specify the entry option) | |
| // webpack watches dependencies | |
| // webpack configuration | |
| target: "web", | |
| debug: true, | |
| plugins: [ | |
| new RewirePlugin(), | |
| new Webpack.IgnorePlugin(/^jquery/) | |
| ], | |
| // configs shared between environments | |
| module: webpackModule, | |
| resolve: webpackResolve | |
| }, | |
| webpackServer: { | |
| // webpack-dev-server configuration | |
| // webpack-dev-middleware configuration | |
| // i. e. | |
| noInfo: true | |
| }, | |
| // the port used by the webpack-dev-server | |
| // defaults to "config.port" + 1 | |
| webpackPort: 1234 | |
| }); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var webpackModule = require('./webpack.module.js'); | |
| var webpackResolve = require('./webpack.resolve.js'); | |
| var Webpack = require('webpack'); | |
| var config = { | |
| target: "web", | |
| debug: true, | |
| entry: { | |
| 'app': './source/main.jsx' | |
| }, | |
| output: { | |
| filename: '[name].bundle.js', | |
| path: './build' | |
| }, | |
| plugins: [ | |
| new Webpack.IgnorePlugin(/^jquery/) | |
| ], | |
| // configs shared between environments | |
| module: webpackModule, | |
| resolve: webpackResolve | |
| }; | |
| module.exports = config; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Common webpack `module` config; common to all environments. | |
| */ | |
| module.exports = { | |
| loaders: [ | |
| { | |
| test: /\.jsx$/, | |
| loader: 'jsx-loader' | |
| },{ | |
| test: /\.css$/, | |
| loader: 'style-loader!css-loader' | |
| },{ | |
| test: /\.less$/, | |
| loader: 'style-loader!css-loader!less-loader' | |
| } | |
| ] | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var path = require('path'); | |
| /* | |
| Common webpack `resolve` config; common to all environments. | |
| */ | |
| module.exports = { | |
| alias: { | |
| "app": path.normalize(__dirname + "/source"), | |
| "app-spec": path.normalize(__dirname + "/spec") | |
| }, | |
| extensions: ["", ".webpack.js", ".web.js", ".jsx", ".js", ".less", ".css"] | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment