Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dir : 'coverage/'
},
webpackMiddleware: {
// webpack-dev-middleware configuration
// i. e.
noInfo: true
},
webpack: {
resolve: {
// Everything relative to repo root
root: path.resolve(path.join(__dirname, '..', '..'))
},
plugins: [
new webpack.ProvidePlugin(require('./karmaWebpackProvidePluginSettings'))
]
}
});
};
module.exports = (skpmConfig, getTestFiles, argv, logProgress) => config => {
config.output.filename = 'compiled-tests.js'
config.output.path = path.resolve(
__dirname,
'../../test-runner.sketchplugin/Contents/Sketch'
)
// https://webpack.js.org/configuration/output/#output-devtoolmodulefilenametemplate
config.output.devtoolModuleFilenameTemplate = '[absolute-resource-path]'
config.plugins.push(
new webpack.ProvidePlugin({
expect: require.resolve('../../expect'),
})
)
if (!argv.buildOnly) {
config.plugins.push(
// eslint-disable-next-line
new WebpackTestRunner({
script: sketchtoolRunCommand(
path.resolve(__dirname, '../../test-runner.sketchplugin'),
'plugin-tests',
{
app: argv.app,
withoutActivating: true,
handleError: false,
}
// External libs
var webpack = require('webpack');
var path = require('path');
// Put React as a global variable
var providePlugin = new webpack.ProvidePlugin({
'React': 'react',
'Immutable': 'immutable',
$: 'jquery',
'window.$': 'jquery',
'window.jQuery': 'jquery',
'jQuery': 'jquery',
'_': 'underscore',
UI: '!json-loader!' + path.resolve(__dirname, './client/style/ui-kit.json'),
'es6-promise': 'es6-promise',
fetch: 'imports?this=>global!exports?global.fetch!whatwg-fetch',
});
var definePlugin = new webpack.DefinePlugin({
'process.env.FIREBASE_API_KEY': JSON.stringify(process.env.FIREBASE_API_KEY),
'process.env.FIREBASE_AUTH_DOMAIN': JSON.stringify(process.env.FIREBASE_AUTH_DOMAIN),
'process.env.FIREBASE_DATABASE_URL': JSON.stringify(process.env.FIREBASE_DATABASE_URL),
//输出位置为./assests
output: {
path: path.join(process.cwd(), 'assets'),
filename: jsDir + '[name].js',
publicPath: '/'
},
plugins: [
//排除css压缩加载在页面
new ExtractTextPlugin(cssDir + '[name].css'),
//合并额外的js包(暂时无用)
// new CommonsChunkPlugin('lib', './dist/js/lib.js', jsExtract),
//开启热加载模式
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
//设置全局使用的变量
new webpack.ProvidePlugin(globalValue),
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
}
})
],
module: {
//加载器配置
loaders: [
//css加载器 排除不需要加css-modules的css部分
{
test: /\.css$/,
exclude: getExcludeCss(),
loaders: [
'style-loader',
'css-loader?modules&localIdentName=[name]__[local]___[hash:base64:5]&sourceMap&importLoaders=1',
config.module.loaders.push(cssLoader);
config.postcss = [
autoprefixer({
browsers: ['last 2 version']
})
];
config.plugins = [
new ExtractTextPlugin('[name].[hash].css', {
disable: !BUILD || TEST
}),
// Provide jquery
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
})
];
if (!TEST) {
config.plugins.push(
new HtmlWebpackPlugin({
template: './public/index.html',
inject: 'body'
})
)
}
if (BUILD) {
function getImplicitGlobals() {
return new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
jquery: 'jquery'
});
}
function provide(app, helpers) {
if (!app.provide) return app
var webpack = require('webpack')
return helpers.injectPlugins(app, new webpack.ProvidePlugin(app.provide))
}
/*
|--------------------------------------------------------------------------
| Plugins
|--------------------------------------------------------------------------
|
| Lastly, we'll register a number of plugins to extend and configure
| Webpack. To get you started, we've included a handful of useful
| extensions, for versioning, OS notifications, and much more.
|
*/
plugins.push(
new webpack.ProvidePlugin(Mix.autoload || {}),
new webpackPlugins.FriendlyErrorsWebpackPlugin({ clearConsole: Mix.options.clearConsole }),
new webpackPlugins.StatsWriterPlugin({
filename: 'mix-manifest.json',
transform: Mix.manifest.transform.bind(Mix.manifest),
}),
new webpack.LoaderOptionsPlugin({
minimize: Mix.inProduction,
options: {
postcss: Mix.options.postCss,
context: __dirname,
output: { path: './' }
}
})
function productionPlugins()
{
return [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}),
new webpack.ProvidePlugin({
URLSearchParams: "url-search-params"
}),
new webpack.optimize.UglifyJsPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(true),
]
}
function plugins(config, isDev) {
var internalKeyDefinitions = Object
.keys(internalKeys)
.reduce((keys, key) => {
keys[key] = `"${internalKeys[key]}"`;
return keys;
}, {});
var plugins = [
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({ DEBUG: isDev }),
new webpack.DefinePlugin(internalKeyDefinitions),
new webpack.ProvidePlugin({ 'Promise': 'es6-promise' }),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.AggressiveMergingPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(true),
new webpack.LoaderOptionsPlugin({
debug: isDev,
queit: true,
silent: true,
minimize: false,
progress: false,
}),
];
if (isDev) {
plugins.push(new WebpackVisualizer());
} else {
plugins.push(new ClosureCompilerPlugin({
compiler: {