This repository has been archived by the owner on Nov 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[webpack] Makes sure it's working with v2
- Loading branch information
1 parent
ce02b7f
commit 8e7dc76
Showing
7 changed files
with
189 additions
and
194 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,63 @@ | ||
// @flow weak | ||
|
||
import path from 'path'; | ||
import HtmlWebpackPlugin from 'html-webpack-plugin'; | ||
import ServiceWorkerWebpackPlugin from '../../src/index'; | ||
|
||
export default { | ||
entry: [ | ||
'./docs/src/app.js', | ||
], | ||
output: { | ||
pathinfo: false, | ||
path: path.join(__dirname, '../dist'), // No used by webpack dev server | ||
publicPath: '', | ||
filename: 'app.js', | ||
}, | ||
target: 'web', | ||
resolve: { | ||
extensions: ['.js'], | ||
alias: { | ||
'serviceworker-webpack-plugin/lib': path.resolve(__dirname, '../../src'), | ||
}, | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
loader: 'babel-loader', | ||
}, | ||
{ | ||
test: /\.scss$/, | ||
loaders: [ | ||
'style-loader', | ||
'css-loader', | ||
'postcss-loader', | ||
'sass-loader', | ||
], | ||
}, | ||
], | ||
}, | ||
performance: { | ||
maxAssetSize: 4e6, | ||
maxEntrypointSize: 6e6, | ||
}, | ||
plugins: [ | ||
new HtmlWebpackPlugin({ | ||
template: path.join(__dirname, '../src/index.html'), | ||
minify: { | ||
removeComments: true, | ||
collapseWhitespace: true, | ||
}, | ||
}), | ||
new ServiceWorkerWebpackPlugin({ | ||
entry: path.join(__dirname, '../src/sw.js'), | ||
excludes: [ | ||
'**/.*', | ||
'**/*.map', | ||
'*.html', | ||
], | ||
}), | ||
], | ||
}; |
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,71 @@ | ||
// @flow weak | ||
|
||
import webpack from 'webpack'; | ||
import ForceCaseSensitivityPlugin from 'force-case-sensitivity-webpack-plugin'; | ||
import baseConfig from './baseConfig'; | ||
|
||
const PORT = 8002; | ||
|
||
export default { | ||
...baseConfig, | ||
output: { | ||
...baseConfig.output, | ||
// * filename */ comments to generated require()s in the output. | ||
pathinfo: true, | ||
publicPath: '/', | ||
}, | ||
// webpack-dev-server options. | ||
devServer: { | ||
// activate hot reloading. | ||
hot: true, | ||
historyApiFallback: true, | ||
port: PORT, | ||
|
||
// webpack-dev-middleware options. | ||
stats: { | ||
// Remove built modules information. | ||
modules: false, | ||
// Remove built modules information to chunk information. | ||
chunkModules: false, | ||
colors: true, | ||
}, | ||
}, | ||
module: { | ||
rules: [ | ||
...baseConfig.module.rules.map((rule) => { | ||
if (rule.use === 'babel-loader') { | ||
return { | ||
...rule, | ||
options: { | ||
presets: [ | ||
['es2015', { | ||
modules: false, | ||
}], | ||
], | ||
plugins: [ | ||
'react-hot-loader/babel', | ||
], | ||
}, | ||
}; | ||
} | ||
|
||
return rule; | ||
}), | ||
], | ||
}, | ||
devtool: 'eval', // no SourceMap, but named modules. Fastest at the expense of detail. | ||
plugins: [ | ||
...baseConfig.plugins, | ||
// Prevent naming issues. | ||
new ForceCaseSensitivityPlugin(), | ||
// Activates HMR. | ||
new webpack.HotModuleReplacementPlugin(), | ||
// Prints more readable module names in the browser console on HMR updates. | ||
new webpack.NamedModulesPlugin(), | ||
new webpack.DefinePlugin({ | ||
'process.env': { | ||
NODE_ENV: JSON.stringify('development'), | ||
}, | ||
}), | ||
], | ||
}; |
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,45 @@ | ||
// @flow weak | ||
|
||
import webpack from 'webpack'; | ||
import baseConfig from './baseConfig'; | ||
|
||
export default { | ||
...baseConfig, | ||
module: { | ||
rules: [ | ||
...baseConfig.module.rules.map((rule) => { | ||
if (rule.use === 'babel-loader') { | ||
return { | ||
...rule, | ||
options: { | ||
presets: [ | ||
['es2015', { | ||
modules: false, | ||
}], | ||
], | ||
}, | ||
}; | ||
} | ||
|
||
return rule; | ||
}), | ||
], | ||
}, | ||
plugins: [ | ||
...baseConfig.plugins, | ||
new webpack.optimize.UglifyJsPlugin({ | ||
compress: { | ||
warnings: false, | ||
screw_ie8: true, | ||
}, | ||
output: { | ||
comments: false, | ||
}, | ||
}), | ||
new webpack.DefinePlugin({ | ||
'process.env': { | ||
NODE_ENV: JSON.stringify('production'), | ||
}, | ||
}), | ||
], | ||
}; |
Oops, something went wrong.