Promact / md2

Angular2 based Material Design components, directives and services are Accordion, Autocomplete, Collapse, Colorpicker, Datepicker, Dialog(Modal), Menu, Multiselect, Select, Tabs, Tags(Chips), Toast and Tooltip.
http://code.promactinfo.com/md2/
MIT License
379 stars 112 forks source link

AOT compilation error on md2@0.0.19 #202

Closed VagrantAI-c closed 7 years ago

VagrantAI-c commented 7 years ago

I imported md2@0.0.19 into my app.module.ts:

import { Md2Module } from 'md2';
...
imports: [
    Md2Module.forRoot(),
]

and trying to AOT compile angular 4.1.1 app from webpack angular starter seed with npm run build:aot command and getting next error:

Starting compilation using the angular compiler.
Angular compilation done, starting webpack bundling.
ReferenceError: window is not defined
    at {project_dir}/node_modules/md2/accordion/accordion.css:105:10
    at {project_dir}/node_modules/md2/accordion/accordion.css:95:47
    at module.exports ({project_dir}/node_modules/md2/accordion/accordion.css:133:68)
    at Object.<anonymous> ({project_dir}/node_modules/md2/accordion/accordion.css:588:36)
    at __webpack_require__ ({project_dir}/node_modules/md2/accordion/accordion.css:20:30)
    at {project_dir}/node_modules/md2/accordion/accordion.css:66:18
    at {project_dir}/node_modules/md2/accordion/accordion.css:69:10
    at ContextifyScript.Script.runInContext (vm.js:35:29)
    at WebpackResourceLoader._evaluate ({project_dir}\node_modules\ngc-webpack\src\webpack-resource-loader.js:95:34)
    at {project_dir}\node_modules\ngc-webpack\src\webpack-resource-loader.js:108:52

Something is definitely wrong that compiler points to css file, but removing md2 module from app.module.ts and compiling app then works just fine

VagrantAI-c commented 7 years ago

Actually fixed this by changing css loader from {test: /\.css$/, loader: 'style-loader!css-loader?-minimize', exclude: /src/}, to {test: /\.css$/, use: ['to-string-loader', 'css-loader'], exclude: /src/}, in webpack.common.js. I wonder if the problem was actually on my side.