forked from Semantic-Org/Semantic-UI-React
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5acee5
commit 280d97f
Showing
37 changed files
with
573 additions
and
587 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,5 @@ | |
"es2015", | ||
"react", | ||
"stage-1" | ||
], | ||
"plugins": [ | ||
"add-module-exports" | ||
] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { argv } from 'yargs' | ||
import config from '../config' | ||
import webpackConfig from './webpack.config' | ||
const { paths } = config | ||
|
||
module.exports = (karmaConfig) => { | ||
karmaConfig.set({ | ||
basePath: process.cwd(), | ||
browsers: ['PhantomJS'], | ||
singleRun: !argv.watch, | ||
reporters: ['mocha'], | ||
files: [ | ||
'./node_modules/babel-polyfill/dist/polyfill.js', | ||
'./node_modules/phantomjs-polyfill/bind-polyfill.js', | ||
'./test/tests.bundle.js', | ||
], | ||
frameworks: ['mocha'], | ||
preprocessors: { | ||
'**/*.bundle.js': ['webpack', 'sourcemap'], | ||
}, | ||
client: { | ||
mocha: { | ||
reporter: 'html', // change Karma's debug.html to mocha web reporter | ||
ui: 'bdd', | ||
}, | ||
}, | ||
webpack: { | ||
devtool: 'inline-source-map', | ||
module: { | ||
...webpackConfig.module, | ||
loaders: [ | ||
{ | ||
test: /sinon\.js$/, | ||
loader: 'imports?define=>false,require=>false', | ||
}, | ||
{ | ||
test: /\.js$/, | ||
loaders: ['babel', 'eslint'], | ||
exclude: paths.base('node_modules'), | ||
}, | ||
{ | ||
test: /\.json$/, | ||
loaders: ['json'], | ||
exclude: paths.base('node_modules'), | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
...webpackConfig.resolve, | ||
alias: { | ||
...webpackConfig.resolve.alias, | ||
jquery: `${paths.test('mocks')}/SemanticjQuery-mock.js`, | ||
sinon: 'sinon/pkg/sinon', | ||
}, | ||
}, | ||
}, | ||
webpackServer: { | ||
progress: false, | ||
stats: config.compiler_stats, | ||
debug: true, | ||
noInfo: false, | ||
quiet: false, | ||
}, | ||
}) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
import config from '../config' | ||
import webpack from 'webpack' | ||
import HtmlWebpackPlugin from 'html-webpack-plugin' | ||
import _ from 'lodash' | ||
|
||
const { paths } = config | ||
const { __DEV__, __TEST__ } = config.compiler_globals | ||
|
||
const webpackConfig = { | ||
name: 'client', | ||
target: 'web', | ||
devtool: config.compiler_devtool, | ||
resolve: { | ||
root: paths.base(), | ||
alias: { | ||
stardust: paths.src('index.js'), | ||
}, | ||
}, | ||
externals: { | ||
bluebird: 'Promise', | ||
faker: 'faker', | ||
jquery: 'jQuery', | ||
lodash: '_', | ||
}, | ||
module: {}, | ||
} | ||
|
||
// ------------------------------------ | ||
// Entry Points | ||
// ------------------------------------ | ||
|
||
const webpackHotPath = `${config.compiler_public_path}__webpack_hmr` | ||
|
||
const webpackHotMiddlewareEntry = 'webpack-hot-middleware/client?' + _.map({ | ||
path: webpackHotPath, // The path which the middleware is serving the event stream on | ||
timeout: 2000, // The time to wait after a disconnection before attempting to reconnect | ||
overlay: true, // Set to false to disable the DOM-based client-side overlay. | ||
reload: true, // Set to true to auto-reload the page when webpack gets stuck. | ||
noInfo: false, // Set to true to disable informational console logging. | ||
quiet: false, // Set to true to disable all console logging. | ||
}, (val, key) => `&${key}=${val}`).join('') | ||
|
||
const APP_ENTRY = paths.docsSrc('DocsApp.js') | ||
|
||
webpackConfig.entry = { | ||
app: __DEV__ | ||
? [webpackHotMiddlewareEntry, APP_ENTRY] | ||
: [APP_ENTRY], | ||
vendor: [ | ||
webpackHotMiddlewareEntry, | ||
'babel-polyfill', | ||
...config.compiler_vendor, | ||
], | ||
} | ||
|
||
// ------------------------------------ | ||
// Bundle Output | ||
// ------------------------------------ | ||
webpackConfig.output = { | ||
filename: `[name].[${config.compiler_hash_type}].js`, | ||
path: config.compiler_output_path, | ||
publicPath: config.compiler_public_path, | ||
pathinfo: true, | ||
} | ||
|
||
// ------------------------------------ | ||
// Plugins | ||
// ------------------------------------ | ||
webpackConfig.plugins = [ | ||
new webpack.DefinePlugin(config.compiler_globals), | ||
new HtmlWebpackPlugin({ | ||
template: paths.docsSrc('index.html'), | ||
hash: false, | ||
filename: 'index.html', | ||
inject: 'body', | ||
minify: { | ||
collapseWhitespace: true, | ||
}, | ||
}), | ||
] | ||
|
||
if (__DEV__) { | ||
webpackConfig.plugins.push( | ||
new webpack.HotModuleReplacementPlugin(), | ||
new webpack.NoErrorsPlugin(), | ||
) | ||
} else if (!__TEST__) { | ||
webpackConfig.plugins.push( | ||
new webpack.optimize.OccurrenceOrderPlugin(), | ||
new webpack.optimize.DedupePlugin(), | ||
new webpack.optimize.UglifyJsPlugin({ | ||
compress: { | ||
unused: true, | ||
dead_code: true, | ||
warnings: false, | ||
}, | ||
}) | ||
) | ||
} | ||
|
||
// Don't split bundles during testing, since we only want import one bundle | ||
if (!__TEST__) { | ||
webpackConfig.plugins.push(new webpack.optimize.CommonsChunkPlugin({ | ||
names: ['vendor'], | ||
})) | ||
} | ||
|
||
// ------------------------------------ | ||
// No Parse | ||
// ------------------------------------ | ||
webpackConfig.module.noParse = [ | ||
/autoit.js/, // highlight.js dep throws if parsed | ||
] | ||
|
||
// ------------------------------------ | ||
// Pre-Loaders | ||
// ------------------------------------ | ||
webpackConfig.module.preLoaders = [{ | ||
test: /\.js$/, | ||
loader: 'eslint', | ||
exclude: /node_modules/, | ||
}] | ||
|
||
webpackConfig.eslint = { | ||
configFile: paths.base('.eslintrc'), | ||
emitWarning: __DEV__, | ||
} | ||
|
||
// ------------------------------------ | ||
// Loaders | ||
// ------------------------------------ | ||
webpackConfig.module.loaders = [{ | ||
// | ||
// Babel | ||
// | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
loader: 'babel', | ||
query: { | ||
cacheDirectory: true, | ||
plugins: [], | ||
presets: ['es2015', 'react', 'stage-1'], | ||
env: { | ||
development: { | ||
plugins: [ | ||
['react-transform', { | ||
transforms: [{ | ||
transform: 'react-transform-hmr', | ||
imports: ['react'], | ||
locals: ['module'], | ||
}, { | ||
transform: 'react-transform-catch-errors', | ||
imports: ['react', 'redbox-react'], | ||
}], | ||
}], | ||
], | ||
}, | ||
}, | ||
}, | ||
}, { | ||
// | ||
// JSON | ||
// | ||
test: /\.json$/, | ||
loader: 'json', | ||
}] | ||
|
||
export default webpackConfig |
This file contains 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
Oops, something went wrong.