|
1 |
| -import webpack from 'webpack'; |
2 |
| -import HtmlWebpackPlugin from 'html-webpack-plugin'; |
| 1 | +import webpack from "webpack"; |
| 2 | +import HtmlWebpackPlugin from "html-webpack-plugin"; |
3 | 3 | import postCSSImport from "postcss-import";
|
4 | 4 | import postCSSNested from "postcss-nested";
|
5 | 5 | import postCSSNext from "postcss-cssnext";
|
6 |
| -import path from 'path'; |
7 |
| -const ENV = process.env.NODE_ENV || 'development'; |
| 6 | +import path from "path"; |
| 7 | +const ENV = process.env.NODE_ENV || "development"; |
8 | 8 |
|
9 |
| -const CSS_MAPS = ENV!=='production'; |
| 9 | +const CSS_MAPS = ENV !== "production"; |
10 | 10 |
|
11 | 11 | module.exports = {
|
12 |
| - context: path.resolve(__dirname, "src"), |
13 |
| - entry: { |
14 |
| - 'netlify-identity-widget': './index.js', |
15 |
| - 'netlify-identity': './netlify-identity.js' |
16 |
| - }, |
| 12 | + context: path.resolve(__dirname, "src"), |
| 13 | + entry: { |
| 14 | + "netlify-identity-widget": "./index.js", |
| 15 | + "netlify-identity": "./netlify-identity.js" |
| 16 | + }, |
17 | 17 |
|
18 |
| - output: { |
19 |
| - path: path.resolve(__dirname, "build"), |
20 |
| - publicPath: '/', |
21 |
| - filename: '[name].js' |
22 |
| - }, |
| 18 | + output: { |
| 19 | + path: path.resolve(__dirname, "build"), |
| 20 | + publicPath: "/", |
| 21 | + filename: "[name].js" |
| 22 | + }, |
23 | 23 |
|
24 |
| - resolve: { |
25 |
| - extensions: ['.jsx', '.js', '.json'], |
26 |
| - modules: [ |
27 |
| - path.resolve(__dirname, "src/lib"), |
28 |
| - path.resolve(__dirname, "node_modules"), |
29 |
| - 'node_modules' |
30 |
| - ], |
31 |
| - alias: { |
32 |
| - components: path.resolve(__dirname, "src/components"), // used for tests |
33 |
| - style: path.resolve(__dirname, "src/style"), |
34 |
| - 'react': 'preact-compat', |
35 |
| - 'react-dom': 'preact-compat' |
36 |
| - } |
37 |
| - }, |
| 24 | + resolve: { |
| 25 | + extensions: [".jsx", ".js", ".json"], |
| 26 | + modules: [ |
| 27 | + path.resolve(__dirname, "src/lib"), |
| 28 | + path.resolve(__dirname, "node_modules"), |
| 29 | + "node_modules" |
| 30 | + ], |
| 31 | + alias: { |
| 32 | + components: path.resolve(__dirname, "src/components"), // used for tests |
| 33 | + style: path.resolve(__dirname, "src/style"), |
| 34 | + react: "preact-compat", |
| 35 | + "react-dom": "preact-compat" |
| 36 | + } |
| 37 | + }, |
38 | 38 |
|
39 |
| - module: { |
40 |
| - rules: [ |
41 |
| - { |
42 |
| - test: /\.jsx?$/, |
43 |
| - exclude: path.resolve(__dirname, 'src'), |
44 |
| - enforce: 'pre', |
45 |
| - use: 'source-map-loader' |
46 |
| - }, |
47 |
| - { |
48 |
| - test: /\.jsx?$/, |
49 |
| - exclude: /node_modules/, |
50 |
| - use: 'babel-loader' |
51 |
| - }, |
52 |
| - { |
53 |
| - // Transform our own .(less|css) files with PostCSS and CSS-modules |
54 |
| - test: /\.(css)$/, |
55 |
| - include: [path.resolve(__dirname, 'src/components')], |
56 |
| - use: [ |
57 |
| - { |
58 |
| - loader: 'css-loader', |
59 |
| - options: { importLoaders: 1 } |
60 |
| - }, |
61 |
| - { |
62 |
| - loader: `postcss-loader`, |
63 |
| - options: { |
64 |
| - sourceMap: CSS_MAPS, |
65 |
| - plugins: () => [ |
66 |
| - postCSSImport(), |
67 |
| - postCSSNested(), |
68 |
| - postCSSNext() |
69 |
| - ] |
70 |
| - } |
71 |
| - } |
72 |
| - ] |
73 |
| - }, |
74 |
| - { |
75 |
| - test: /\.json$/, |
76 |
| - use: 'json-loader' |
77 |
| - }, |
78 |
| - { |
79 |
| - test: /\.(xml|html|txt|md)$/, |
80 |
| - use: 'raw-loader' |
81 |
| - }, |
82 |
| - { |
83 |
| - test: /\.(svg|woff2?|ttf|eot|jpe?g|png|gif)(\?.*)?$/i, |
84 |
| - use: ENV==='production' ? 'file-loader' : 'url-loader' |
85 |
| - } |
86 |
| - ] |
87 |
| - }, |
88 |
| - plugins: ([ |
89 |
| - new webpack.NoEmitOnErrorsPlugin(), |
90 |
| - new webpack.DefinePlugin({ |
91 |
| - 'process.env.NODE_ENV': JSON.stringify(ENV) |
92 |
| - }), |
93 |
| - new HtmlWebpackPlugin({ |
94 |
| - template: './index.ejs', |
95 |
| - minify: { collapseWhitespace: true } |
96 |
| - }) |
97 |
| - ]).concat(ENV==='production' ? [ |
98 |
| - new webpack.optimize.UglifyJsPlugin({ |
99 |
| - output: { |
100 |
| - comments: false |
101 |
| - }, |
102 |
| - compress: { |
103 |
| - unsafe_comps: true, |
104 |
| - properties: true, |
105 |
| - keep_fargs: false, |
106 |
| - pure_getters: true, |
107 |
| - collapse_vars: true, |
108 |
| - unsafe: true, |
109 |
| - warnings: false, |
110 |
| - screw_ie8: true, |
111 |
| - sequences: true, |
112 |
| - dead_code: true, |
113 |
| - drop_debugger: true, |
114 |
| - comparisons: true, |
115 |
| - conditionals: true, |
116 |
| - evaluate: true, |
117 |
| - booleans: true, |
118 |
| - loops: true, |
119 |
| - unused: true, |
120 |
| - hoist_funs: true, |
121 |
| - if_return: true, |
122 |
| - join_vars: true, |
123 |
| - cascade: true, |
124 |
| - drop_console: true |
125 |
| - } |
126 |
| - }) |
127 |
| - ] : []), |
| 39 | + module: { |
| 40 | + rules: [ |
| 41 | + { |
| 42 | + test: /\.jsx?$/, |
| 43 | + exclude: path.resolve(__dirname, "src"), |
| 44 | + enforce: "pre", |
| 45 | + use: "source-map-loader" |
| 46 | + }, |
| 47 | + { |
| 48 | + test: /\.jsx?$/, |
| 49 | + exclude: /node_modules/, |
| 50 | + use: "babel-loader" |
| 51 | + }, |
| 52 | + { |
| 53 | + // Transform our own .(less|css) files with PostCSS and CSS-modules |
| 54 | + test: /\.(css)$/, |
| 55 | + include: [path.resolve(__dirname, "src/components")], |
| 56 | + use: [ |
| 57 | + { |
| 58 | + loader: "css-loader", |
| 59 | + options: { importLoaders: 1 } |
| 60 | + }, |
| 61 | + { |
| 62 | + loader: `postcss-loader`, |
| 63 | + options: { |
| 64 | + sourceMap: CSS_MAPS, |
| 65 | + plugins: () => [postCSSImport(), postCSSNested(), postCSSNext()] |
| 66 | + } |
| 67 | + } |
| 68 | + ] |
| 69 | + }, |
| 70 | + { |
| 71 | + test: /\.json$/, |
| 72 | + use: "json-loader" |
| 73 | + }, |
| 74 | + { |
| 75 | + test: /\.(xml|html|txt|md)$/, |
| 76 | + use: "raw-loader" |
| 77 | + }, |
| 78 | + { |
| 79 | + test: /\.(svg|woff2?|ttf|eot|jpe?g|png|gif)(\?.*)?$/i, |
| 80 | + use: ENV === "production" ? "file-loader" : "url-loader" |
| 81 | + } |
| 82 | + ] |
| 83 | + }, |
| 84 | + plugins: [ |
| 85 | + new webpack.NoEmitOnErrorsPlugin(), |
| 86 | + new webpack.DefinePlugin({ |
| 87 | + "process.env.NODE_ENV": JSON.stringify(ENV) |
| 88 | + }), |
| 89 | + new HtmlWebpackPlugin({ |
| 90 | + template: "./index.ejs", |
| 91 | + minify: { collapseWhitespace: true } |
| 92 | + }) |
| 93 | + ].concat( |
| 94 | + ENV === "production" |
| 95 | + ? [ |
| 96 | + new webpack.optimize.UglifyJsPlugin({ |
| 97 | + output: { |
| 98 | + comments: false |
| 99 | + }, |
| 100 | + compress: { |
| 101 | + unsafe_comps: true, |
| 102 | + properties: true, |
| 103 | + keep_fargs: false, |
| 104 | + pure_getters: true, |
| 105 | + collapse_vars: true, |
| 106 | + unsafe: true, |
| 107 | + warnings: false, |
| 108 | + screw_ie8: true, |
| 109 | + sequences: true, |
| 110 | + dead_code: true, |
| 111 | + drop_debugger: true, |
| 112 | + comparisons: true, |
| 113 | + conditionals: true, |
| 114 | + evaluate: true, |
| 115 | + booleans: true, |
| 116 | + loops: true, |
| 117 | + unused: true, |
| 118 | + hoist_funs: true, |
| 119 | + if_return: true, |
| 120 | + join_vars: true, |
| 121 | + cascade: true, |
| 122 | + drop_console: true |
| 123 | + } |
| 124 | + }) |
| 125 | + ] |
| 126 | + : [] |
| 127 | + ), |
128 | 128 |
|
129 |
| - stats: { colors: true }, |
| 129 | + stats: { colors: true }, |
130 | 130 |
|
131 |
| - node: { |
132 |
| - global: true, |
133 |
| - process: false, |
134 |
| - Buffer: false, |
135 |
| - __filename: false, |
136 |
| - __dirname: false, |
137 |
| - setImmediate: false |
138 |
| - }, |
| 131 | + node: { |
| 132 | + global: true, |
| 133 | + process: false, |
| 134 | + Buffer: false, |
| 135 | + __filename: false, |
| 136 | + __dirname: false, |
| 137 | + setImmediate: false |
| 138 | + }, |
139 | 139 |
|
140 |
| - devtool: ENV==='production' ? 'source-map' : 'cheap-module-eval-source-map', |
| 140 | + devtool: ENV === "production" ? "source-map" : "cheap-module-eval-source-map", |
141 | 141 |
|
142 |
| - devServer: { |
143 |
| - port: process.env.PORT || 8080, |
144 |
| - host: 'localhost', |
145 |
| - publicPath: '/', |
146 |
| - contentBase: './src', |
147 |
| - historyApiFallback: true, |
148 |
| - open: true, |
149 |
| - openPage: '', |
150 |
| - proxy: { |
151 |
| - // OPTIONAL: proxy configuration: |
152 |
| - // '/optional-prefix/**': { // path pattern to rewrite |
153 |
| - // target: 'http://target-host.com', |
154 |
| - // pathRewrite: path => path.replace(/^\/[^\/]+\//, '') // strip first path segment |
155 |
| - // } |
156 |
| - } |
157 |
| - } |
| 142 | + devServer: { |
| 143 | + port: process.env.PORT || 8080, |
| 144 | + host: "localhost", |
| 145 | + publicPath: "/", |
| 146 | + contentBase: "./src", |
| 147 | + historyApiFallback: true, |
| 148 | + open: true, |
| 149 | + openPage: "", |
| 150 | + proxy: { |
| 151 | + // OPTIONAL: proxy configuration: |
| 152 | + // '/optional-prefix/**': { // path pattern to rewrite |
| 153 | + // target: 'http://target-host.com', |
| 154 | + // pathRewrite: path => path.replace(/^\/[^\/]+\//, '') // strip first path segment |
| 155 | + // } |
| 156 | + } |
| 157 | + } |
158 | 158 | };
|
0 commit comments