Skip to content

Commit ea2b644

Browse files
author
Nick Balestra
committed
better ad hoc webpack configs
1 parent bcef3e7 commit ea2b644

File tree

4 files changed

+147
-7
lines changed

4 files changed

+147
-7
lines changed

packages/cycle-scripts/scripts/configs/webpack.config.dev.js renamed to packages/cycle-scripts/configs/webpack.config.dev.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ const webpack = require('webpack')
77
module.exports = {
88
entry: {
99
main: [
10-
require.resolve('../utils/webpackHotDevClient'),
11-
// `webpack-dev-server/client?http://${devServer.host}:${devServer.port.toString()}`,
12-
// 'webpack/hot/dev-server', // 'webpack/hot/only-dev-server',
10+
require.resolve('cycle-dev-utils/webpackHotDevClient'),
1311
path.join(process.cwd(), 'src', 'index.js')
1412
]
1513
},
@@ -23,7 +21,17 @@ module.exports = {
2321
test: /\.jsx?$/,
2422
loader: 'babel-loader',
2523
options: {
26-
cacheDirectory: true
24+
cacheDirectory: true,
25+
presets: [
26+
[ 'env', {
27+
'targets': {
28+
'browsers': ['last 2 versions']
29+
}
30+
}]
31+
],
32+
plugins: [
33+
['transform-react-jsx', { pragma: 'Snabbdom.createElement' }]
34+
]
2735
},
2836
exclude: /node_modules/
2937
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
'use strict'
2+
3+
const path = require('path')
4+
const HtmlWebpackPlugin = require('html-webpack-plugin')
5+
const webpack = require('webpack')
6+
7+
module.exports = {
8+
entry: {
9+
main: [
10+
path.join(process.cwd(), 'src', 'index.js')
11+
]
12+
},
13+
output: {
14+
filename: 'bundle.js',
15+
path: path.join(process.cwd(), 'build')
16+
},
17+
module: {
18+
rules: [
19+
{
20+
test: /\.jsx?$/,
21+
loader: 'babel-loader',
22+
options: {
23+
cacheDirectory: true,
24+
presets: [
25+
[ 'env', {
26+
'targets': {
27+
'browsers': ['last 2 versions'],
28+
uglify: true
29+
}
30+
}]
31+
],
32+
plugins: [
33+
['transform-react-jsx', { pragma: 'Snabbdom.createElement' }]
34+
]
35+
},
36+
exclude: /node_modules/
37+
}
38+
]
39+
},
40+
plugins: [
41+
new webpack.HotModuleReplacementPlugin(),
42+
new HtmlWebpackPlugin({
43+
template: 'public/index.html',
44+
inject: true,
45+
favicon: 'public/favicon.png',
46+
hash: true
47+
}),
48+
new webpack.ProvidePlugin({
49+
Snabbdom: 'snabbdom-pragma'
50+
}),
51+
new webpack.optimize.UglifyJsPlugin(),
52+
new webpack.LoaderOptionsPlugin({
53+
minimize: true,
54+
debug: false
55+
})
56+
]
57+
}
58+
59+
// 'use strict'
60+
61+
// const fs = require('fs-extra')
62+
// const path = require('path')
63+
// const mkdirp = require('mkdirp')
64+
// const webpack = require('webpack')
65+
// const ProgressBarPlugin = require('progress-bar-webpack-plugin')
66+
67+
// const buildPath = path.join(process.cwd(), 'build')
68+
// const publicPath = path.join(process.cwd(), 'public')
69+
70+
// mkdirp.sync(buildPath)
71+
72+
// const compiler = webpack({
73+
// entry: [
74+
// './src/'
75+
// ],
76+
// output: {
77+
// filename: 'bundle.js',
78+
// path: './public/'
79+
// },
80+
// module: {
81+
// loaders: [
82+
// {
83+
// test: /\.js$/,
84+
// loader: 'babel',
85+
// query: {
86+
// presets: ['es2015']
87+
// },
88+
// exclude: /node_modules/
89+
// }
90+
// ]
91+
// },
92+
// plugins: [
93+
// new ProgressBarPlugin(),
94+
// new webpack.optimize.UglifyJsPlugin({minimize: true})
95+
// ]
96+
// })
97+
98+
// compiler.run((err, stats) => {
99+
// if (err) {
100+
// console.log(err)
101+
// } else {
102+
// fs.copySync(publicPath, buildPath)
103+
// }
104+
// })

packages/cycle-scripts/scripts/configs/webpackDevServer.config.js renamed to packages/cycle-scripts/configs/webpackDevServer.config.js

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,43 @@
11
/**
2-
* Source: https://github.com/facebookincubator/create-react-app/
2+
* BSD License
3+
* For create-react-app software
4+
*
5+
* Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
6+
* Redistribution and use in source and binary forms, with or without modification,
7+
* are permitted provided that the following conditions are met:
8+
*
9+
* Redistributions of source code must retain the above copyright notice, this
10+
* list of conditions and the following disclaimer.
11+
*
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following disclaimer in the documentation
14+
* and/or other materials provided with the distribution.
15+
*
16+
* Neither the name Facebook nor the names of its contributors may be used to
17+
* endorse or promote products derived from this software without specific
18+
* prior written permission.
19+
*
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
25+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
331
*/
32+
433
'use strict'
34+
535
const fs = require('fs')
636
const path = require('path')
737

838
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http'
939
const host = process.env.HOST || 'localhost'
1040

11-
// to be moved in paths.js file
1241
const appDirectory = fs.realpathSync(process.cwd())
1342
function resolveApp (relativePath) {
1443
return path.resolve(appDirectory, relativePath)

packages/cycle-scripts/scripts/configs/webpack.config.prod.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)